mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-01-06 13:17:44 +03:00
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 byacfc2a1d15
. Fixes #25702. (cherry picked from commiteb18e7b782
)
This commit is contained in:
parent
13de548fca
commit
aeb3653744
@ -2333,9 +2333,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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user