X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Flibsystemd-bus%2Fbus-objects.c;h=5aa83a44262c4952156b1c254b3e13dde5e20a06;hb=2fd069b18e525860514a70d3ea08410ca122d3e2;hp=8c81ea664149633ea48379b6a81d9ab1fc2baea8;hpb=9bfa2c029d4367406bda9b8984e579e0b06b3b2b;p=elogind.git diff --git a/src/libsystemd-bus/bus-objects.c b/src/libsystemd-bus/bus-objects.c index 8c81ea664..5aa83a442 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; }