systemd/0001-core-fix-resource-leak-in-manager_environment_add.patch

33 lines
956 B
Diff
Raw Normal View History

From aa9f8a30fd7dc7aa3aa2575b75b3f9a0ab3f02db Mon Sep 17 00:00:00 2001
From: Andreas Henriksson <andreas@fatal.se>
Date: Tue, 16 Sep 2014 21:11:02 +0200
Subject: [PATCH] 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
---
src/core/manager.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git src/core/manager.c src/core/manager.c
index 0770727..e0c1cd1 100644
--- src/core/manager.c
+++ src/core/manager.c
@@ -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;
}
--
1.7.9.2