chiark / gitweb /
Fix resource leak (coverity CID 1237760)
authorCristian Rodríguez <crrodriguez@opensuse.org>
Wed, 17 Sep 2014 21:10:21 +0000 (18:10 -0300)
committerDaniel Mack <daniel@zonque.org>
Thu, 18 Sep 2014 08:13:09 +0000 (10:13 +0200)
src/libsystemd/sd-bus/bus-kernel.c

index 505f335..b3cc996 100644 (file)
@@ -1446,9 +1446,11 @@ int bus_kernel_create_endpoint(const char *bus_name, const char *ep_name, char *
         }
 
         if (ep_path) {
-                asprintf(ep_path, "%s/%s", dirname(path), ep_name);
-                if (!*ep_path)
+                int r = asprintf(ep_path, "%s/%s", dirname(path), ep_name);
+                if (r == -1 || !*ep_path) {
+                        safe_close(fd);
                         return -ENOMEM;
+                }
         }
 
         return fd;