[systemd-devel] [PATCH] sysv-generator: fix resource leak

Andreas Henriksson andreas at fatal.se
Tue Sep 16 12:22:59 PDT 2014


The "unit" string allocation is not freed on either error or success path.

Found by coverity. Fixes: CID#1237755
---
 src/sysv-generator/sysv-generator.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/sysv-generator/sysv-generator.c b/src/sysv-generator/sysv-generator.c
index 6c3281f..e5902ab 100644
--- a/src/sysv-generator/sysv-generator.c
+++ b/src/sysv-generator/sysv-generator.c
@@ -114,9 +114,9 @@ static int add_symlink(const char *service, const char *where) {
 }
 
 static int generate_unit_file(SysvStub *s) {
-        char *unit;
         char **p;
         _cleanup_fclose_ FILE *f = NULL;
+        _cleanup_free_ char *unit = NULL;
         _cleanup_free_ char *before = NULL;
         _cleanup_free_ char *after = NULL;
         _cleanup_free_ char *wants = NULL;
-- 
2.1.0



More information about the systemd-devel mailing list