From bf84dc168c23872a3e6b37c3daa5d26950c82bda Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Tue, 18 Sep 2018 12:49:51 +0900 Subject: hwdb: make trie_node_cleanup() can take NULL --- src/hwdb/hwdb.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/hwdb') diff --git a/src/hwdb/hwdb.c b/src/hwdb/hwdb.c index ec96923357..a2c1f7da22 100644 --- a/src/hwdb/hwdb.c +++ b/src/hwdb/hwdb.c @@ -113,6 +113,9 @@ static struct trie_node *node_lookup(const struct trie_node *node, uint8_t c) { static void trie_node_cleanup(struct trie_node *node) { size_t i; + if (!node) + return; + for (i = 0; i < node->children_count; i++) trie_node_cleanup(node->children[i].child); free(node->children); @@ -124,9 +127,7 @@ static void trie_free(struct trie *trie) { if (!trie) return; - if (trie->root) - trie_node_cleanup(trie->root); - + trie_node_cleanup(trie->root); strbuf_cleanup(trie->strings); free(trie); } -- cgit v1.2.1