[systemd-commits] 2 commits - src/tmpfiles src/udev
Zbigniew JÄdrzejewski-Szmek
zbyszek at kemper.freedesktop.org
Fri Jul 19 07:04:08 PDT 2013
src/tmpfiles/tmpfiles.c | 8 +++++++-
src/udev/collect/collect.c | 6 +++---
src/udev/udevadm-hwdb.c | 4 +++-
3 files changed, 13 insertions(+), 5 deletions(-)
New commits:
commit e2f2fb786059fbed410938f16e5cc8b851366b14
Author: Maciej Wereski <m.wereski at partner.samsung.com>
Date: Fri Jul 19 15:43:12 2013 +0200
tmpfiles: Fix memory leak in parse_line()
diff --git a/src/tmpfiles/tmpfiles.c b/src/tmpfiles/tmpfiles.c
index 555347a..eae993e 100644
--- a/src/tmpfiles/tmpfiles.c
+++ b/src/tmpfiles/tmpfiles.c
@@ -971,6 +971,12 @@ static void item_free(Item *i) {
free(i);
}
+static inline void item_freep(Item **i) {
+ if (*i)
+ item_free(*i);
+}
+#define _cleanup_item_free_ _cleanup_(item_freep)
+
static bool item_equal(Item *a, Item *b) {
assert(a);
assert(b);
@@ -1013,7 +1019,7 @@ static bool item_equal(Item *a, Item *b) {
}
static int parse_line(const char *fname, unsigned line, const char *buffer) {
- _cleanup_free_ Item *i = NULL;
+ _cleanup_item_free_ Item *i = NULL;
Item *existing;
_cleanup_free_ char
*mode = NULL, *user = NULL, *group = NULL, *age = NULL;
commit ef89eef77ee098a6828169a6d0d74128e236bcbd
Author: Zbigniew JÄdrzejewski-Szmek <zbyszek at in.waw.pl>
Date: Thu Jul 18 19:36:55 2013 -0400
udev: fix two trivial memleaks in error path
Based-on-a-patch-by: Ian Stakenvicius <axs at gentoo.org>
diff --git a/src/udev/collect/collect.c b/src/udev/collect/collect.c
index f95ee23..1346f27 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 4136b17..d9dc73b 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);
}
More information about the systemd-commits
mailing list