sd-device: fix double-free
If an attribute is read but the value is not used (i.e. ret_value is NULL),
then sd_device_get_sysattr_value() mistakenly frees the read data even though
it is cached internally.
Fixes a bug introduced by acfc2a1d15.
Fixes #25702.
This commit is contained in:
@@ -2332,9 +2332,14 @@ _public_ int sd_device_get_sysattr_value(sd_device *device, const char *sysattr,
|
||||
sysattr, value, ret_value ? "" : ", ignoring");
|
||||
if (ret_value)
|
||||
return r;
|
||||
} else if (ret_value)
|
||||
*ret_value = TAKE_PTR(value);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (ret_value)
|
||||
*ret_value = value;
|
||||
|
||||
TAKE_PTR(value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user