chiark / gitweb /
shared: fix resource leak in config_parse_default_instance
authorAndreas Henriksson <andreas@fatal.se>
Tue, 16 Sep 2014 19:36:26 +0000 (21:36 +0200)
committerDaniel Mack <daniel@zonque.org>
Tue, 16 Sep 2014 19:49:56 +0000 (21:49 +0200)
The recently allocated "printed" is not freed on error path.

Found by coverity. Fixes: CID#1237745

src/shared/install.c

index 5d3fcf5e32bc0ddf2afef1b9ce7c22078d79ebf7..61e572bdf3e99058d09fcfcaa92439283be1f91b 100644 (file)
@@ -1025,8 +1025,10 @@ static int config_parse_default_instance(
         if (r < 0)
                 return r;
 
-        if (!unit_instance_is_valid(printed))
+        if (!unit_instance_is_valid(printed)) {
+                free(printed);
                 return -EINVAL;
+        }
 
         free(i->default_instance);
         i->default_instance = printed;