mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-09-08 13:44:50 +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
) (cherry picked from commitaeb3653744
)
This commit is contained in:
committed by
Zbigniew Jędrzejewski-Szmek
parent
f2f863c51f
commit
8f4d5828aa
@@ -2166,9 +2166,14 @@ _public_ int sd_device_get_sysattr_value(sd_device *device, const char *sysattr,
|
|||||||
sysattr, value, ret_value ? "" : ", ignoring");
|
sysattr, value, ret_value ? "" : ", ignoring");
|
||||||
if (ret_value)
|
if (ret_value)
|
||||||
return r;
|
return r;
|
||||||
} else if (ret_value)
|
|
||||||
*ret_value = TAKE_PTR(value);
|
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ret_value)
|
||||||
|
*ret_value = value;
|
||||||
|
|
||||||
|
TAKE_PTR(value);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user