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 5d3fcf5..61e572b 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;