shared/install: give the borrowed name back before bailing on error

In the unmask path, when install_changes_add() fails the borrowed
*name was not handed back via TAKE_PTR() before returning, so
install_info_clear() freed the caller's strv entry, leaving a dangling
pointer that is double-freed at the caller's strv_free().

Follow-up for f31f10a620
This commit is contained in:
Luca Boccassi
2026-07-01 18:18:00 +01:00
parent 61196f5817
commit 0a869d3882
+3 -1
View File
@@ -2438,8 +2438,10 @@ int unit_file_unmask(
path_is_generator(&lp, info.path)) {
r = install_changes_add(changes, n_changes,
INSTALL_CHANGE_IS_MASKED_GENERATOR, info.name, info.path);
if (r < 0)
if (r < 0) {
TAKE_PTR(info.name); /* Return the borrowed name before bailing */
return r;
}
}
TAKE_PTR(info.name); /* … and give it back here */