The explanation from the previous commit about get_name() applies here
as well; but other than `module_name`, the `error_string` field is
mutable and does indeed need protection. But still, returning a
reference is wrong, because the reference does not need protection;
the pointed-to value does. This can be fixed easily by making the
method return a value instead of a reference. The copy is made while
holding the lock.
Signed-off-by: Max Kellermann <max.kellermann@ionos.com>
const std::string &get_name() const {
return module_name;
}
- const std::string &get_error_string() const {
+ std::string get_error_string() const {
std::lock_guard l(lock) ; return error_string;
}
bool get_can_run() const {