diff options
-rw-r--r-- | src/shared/install.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/shared/install.c b/src/shared/install.c index 8036b0a404..478abac8ab 100644 --- a/src/shared/install.c +++ b/src/shared/install.c @@ -1893,7 +1893,11 @@ int unit_file_unmask( if (!GREEDY_REALLOC0(todo, n_allocated, n_todo + 2)) return -ENOMEM; - todo[n_todo++] = strdup(*i); + todo[n_todo] = strdup(*i); + if (!todo[n_todo]) + return -ENOMEM; + + n_todo++; } strv_uniq(todo); @@ -1941,7 +1945,7 @@ int unit_file_link( unsigned *n_changes) { _cleanup_lookup_paths_free_ LookupPaths paths = {}; - _cleanup_free_ char **todo = NULL; + _cleanup_strv_free_ char **todo = NULL; size_t n_todo = 0, n_allocated = 0; const char *config_path; char **i; @@ -1990,7 +1994,11 @@ int unit_file_link( if (!GREEDY_REALLOC0(todo, n_allocated, n_todo + 2)) return -ENOMEM; - todo[n_todo++] = *i; + todo[n_todo] = strdup(*i); + if (!todo[n_todo]) + return -ENOMEM; + + n_todo++; } strv_uniq(todo); |