chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix a few resource leaks in error paths
[elogind.git]
/
src
/
libsystemd-bus
/
bus-objects.c
diff --git
a/src/libsystemd-bus/bus-objects.c
b/src/libsystemd-bus/bus-objects.c
index 8c81ea664149633ea48379b6a81d9ab1fc2baea8..5aa83a44262c4952156b1c254b3e13dde5e20a06 100644
(file)
--- 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;
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);
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);
p = strndupa(path, MAX(1, path - e));
parent = bus_node_allocate(bus, p);
- if (!parent) {
- free(s);
+ if (!parent)
return NULL;
return NULL;
- }
}
n = new0(struct node, 1);
}
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;
n->parent = parent;
n->path = s;
+ s = NULL; /* do not free */
r = hashmap_put(bus->nodes, s, n);
if (r < 0) {
r = hashmap_put(bus->nodes, s, n);
if (r < 0) {
- free(
s
);
+ free(
n->path
);
free(n);
return NULL;
}
free(n);
return NULL;
}