summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Pitt <martin.pitt@ubuntu.com>2017-01-10 08:41:14 +0100
committerGitHub <noreply@github.com>2017-01-10 08:41:14 +0100
commit4a04597ac8e0a94f9b1ce9f83ea687525b8fffe9 (patch)
tree90599bc7bd34e94ada8cb8260daa12a8fa8b2e10
parentc9f7b4d356a453a01aa77a6bb74ca7ef49732c08 (diff)
parentd054eae6c954baa857170bb60072c8a2ecea0d6b (diff)
Merge pull request #5054 from evverx/fix-double-free-in-link
shared: fix double free in link
-rw-r--r--src/shared/install.c14
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);