mirror of
https://github.com/systemd/systemd.git
synced 2025-03-19 22:50:17 +03:00
systemctl-edit: don't leak the old value of contents
This commit is contained in:
parent
c4a2d475f1
commit
8f3e1b9d01
@ -188,10 +188,12 @@ static int create_edit_temp_file(const char *new_path, const char *original_path
|
||||
|
||||
fprintf(f, "\n\n### %s", *path);
|
||||
if (!isempty(contents)) {
|
||||
contents = strreplace(strstrip(contents), "\n", "\n# ");
|
||||
if (!contents)
|
||||
_cleanup_free_ char *commented_contents = NULL;
|
||||
|
||||
commented_contents = strreplace(strstrip(contents), "\n", "\n# ");
|
||||
if (!commented_contents)
|
||||
return log_oom();
|
||||
fprintf(f, "\n# %s", contents);
|
||||
fprintf(f, "\n# %s", commented_contents);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user