summaryrefslogtreecommitdiff
path: root/src/udev/udevadm-hwdb.c
diff options
context:
space:
mode:
authorIan Stakenvicius <axs@gentoo.org>2013-07-10 13:49:26 -0400
committerAnthony G. Basile <blueness@gentoo.org>2013-07-10 15:14:00 -0400
commitb2cf1c7154577f7f8b9f2404c4a41019db314116 (patch)
tree2069d48492c64bfe4ce461b44b088093aef67311 /src/udev/udevadm-hwdb.c
parent5957c143c1b417f040527133daa86c7014822d2c (diff)
Fix potential memleak and use-after-free errors as reported by clang
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
Diffstat (limited to 'src/udev/udevadm-hwdb.c')
-rw-r--r--src/udev/udevadm-hwdb.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/udev/udevadm-hwdb.c b/src/udev/udevadm-hwdb.c
index ea21f242ae..f5fd7e21f2 100644
--- a/src/udev/udevadm-hwdb.c
+++ b/src/udev/udevadm-hwdb.c
@@ -207,6 +207,7 @@ static int trie_insert(struct trie *trie, struct trie_node *node, const char *se
return -ENOMEM;
off = strbuf_add_string(trie->strings, s, p);
+ free(s); /* fix clang-reported potential memleak */
if (off < 0)
return off;
@@ -303,8 +304,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); /* clang reported memleak , children is thrown away if this fails */
return child_off;
+ }
children[i].c = node->children[i].c;
children[i].child_off = htole64(child_off);
}