diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2013-07-18 19:36:55 -0400 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2013-07-19 09:57:04 -0400 |
commit | ef89eef77ee098a6828169a6d0d74128e236bcbd (patch) | |
tree | e55f3a5fb38cb253d95a70a778e350d25414c8cb /src/udev/collect | |
parent | 86d7de36869429f20d75e34bb3ddb2cfd2470e75 (diff) |
udev: fix two trivial memleaks in error path
Based-on-a-patch-by: Ian Stakenvicius <axs@gentoo.org>
Diffstat (limited to 'src/udev/collect')
-rw-r--r-- | src/udev/collect/collect.c | 6 |
1 files changed, 3 insertions, 3 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 { |