summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2013-07-18 19:36:55 -0400
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2013-07-19 09:57:04 -0400
commitef89eef77ee098a6828169a6d0d74128e236bcbd (patch)
treee55f3a5fb38cb253d95a70a778e350d25414c8cb /src
parent86d7de36869429f20d75e34bb3ddb2cfd2470e75 (diff)
udev: fix two trivial memleaks in error path
Based-on-a-patch-by: Ian Stakenvicius <axs@gentoo.org>
Diffstat (limited to 'src')
-rw-r--r--src/udev/collect/collect.c6
-rw-r--r--src/udev/udevadm-hwdb.c4
2 files changed, 6 insertions, 4 deletions
diff --git a/src/udev/collect/collect.c b/src/udev/collect/collect.c
index f95ee23b75..1346f27f91 100644
--- a/src/udev/collect/collect.c
+++ b/src/udev/collect/collect.c
@@ -442,19 +442,19 @@ int main(int argc, char **argv)
if (debug)
fprintf(stderr, "ID %s: not in database\n", argv[i]);
- him = malloc(sizeof (struct _mate));
+ him = new(struct _mate, 1);
if (!him) {
ret = ENOMEM;
goto out;
}
- him->name = malloc(strlen(argv[i]) + 1);
+ him->name = strdup(argv[i]);
if (!him->name) {
+ free(him);
ret = ENOMEM;
goto out;
}
- strcpy(him->name, argv[i]);
him->state = STATE_NONE;
udev_list_node_append(&him->node, &bunch);
} else {
diff --git a/src/udev/udevadm-hwdb.c b/src/udev/udevadm-hwdb.c
index 4136b17be5..d9dc73bfc1 100644
--- a/src/udev/udevadm-hwdb.c
+++ b/src/udev/udevadm-hwdb.c
@@ -303,8 +303,10 @@ static int64_t trie_store_nodes(struct trie_f *trie, struct trie_node *node) {
int64_t child_off;
child_off = trie_store_nodes(trie, node->children[i].child);
- if (child_off < 0)
+ if (child_off < 0) {
+ free(children);
return child_off;
+ }
children[i].c = node->children[i].c;
children[i].child_off = htole64(child_off);
}