chiark / gitweb /
sysv-generator: fix resource leak
authorAndreas Henriksson <andreas@fatal.se>
Tue, 16 Sep 2014 19:22:59 +0000 (21:22 +0200)
committerDaniel Mack <daniel@zonque.org>
Tue, 16 Sep 2014 19:49:03 +0000 (21:49 +0200)
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

index 6c3281ff1520dcf470fc2366dba47a0b86ac30a9..e5902ab8f8180751b4917990b0c3e999948cee0e 100644 (file)
@@ -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;