core: fix resource leak in manager_environment_add

Second error path must free the (potentially) allocated memory in the
first code chunk before returning.

Found by coverity. Fixes: CID#1237750
This commit is contained in:
Andreas Henriksson 2014-09-16 21:11:02 +02:00 committed by Daniel Mack
parent 06b7f7bd7f
commit aa9f8a30fd
1 changed files with 3 additions and 1 deletions

View File

@ -2751,8 +2751,10 @@ int manager_environment_add(Manager *m, char **minus, char **plus) {
if (!strv_isempty(plus)) {
b = strv_env_merge(2, l, plus);
if (!b)
if (!b) {
strv_free(a);
return -ENOMEM;
}
l = b;
}