diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2013-12-15 16:25:04 -0500 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2013-12-15 17:49:28 -0500 |
commit | 2fd069b18e525860514a70d3ea08410ca122d3e2 (patch) | |
tree | c100efe3f3ddc3d1ddc780ce207f8d5d4821682d /src/libsystemd-bus | |
parent | 9bfa2c029d4367406bda9b8984e579e0b06b3b2b (diff) |
Fix a few resource leaks in error paths
https://bugzilla.redhat.com/show_bug.cgi?id=1043304
Diffstat (limited to 'src/libsystemd-bus')
-rw-r--r-- | src/libsystemd-bus/bus-objects.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/libsystemd-bus/bus-objects.c b/src/libsystemd-bus/bus-objects.c index 8c81ea6641..5aa83a4426 100644 --- a/src/libsystemd-bus/bus-objects.c +++ b/src/libsystemd-bus/bus-objects.c @@ -1338,7 +1338,8 @@ int bus_process_object(sd_bus *bus, sd_bus_message *m) { static struct node *bus_node_allocate(sd_bus *bus, const char *path) { struct node *n, *parent; const char *e; - char *s, *p; + _cleanup_free_ char *s = NULL; + char *p; int r; assert(bus); @@ -1366,10 +1367,8 @@ static struct node *bus_node_allocate(sd_bus *bus, const char *path) { p = strndupa(path, MAX(1, path - e)); parent = bus_node_allocate(bus, p); - if (!parent) { - free(s); + if (!parent) return NULL; - } } n = new0(struct node, 1); @@ -1378,10 +1377,11 @@ static struct node *bus_node_allocate(sd_bus *bus, const char *path) { n->parent = parent; n->path = s; + s = NULL; /* do not free */ r = hashmap_put(bus->nodes, s, n); if (r < 0) { - free(s); + free(n->path); free(n); return NULL; } |