summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Jean-Christophe Dubois <jcd@tribudubois.net> 2016-07-11 00:16:52 +0200
committer David Gibson <david@gibson.dropbear.id.au> 2016-07-11 11:28:28 +1000
commitcb9241ae345378b7193b3d7c9621e8abe657faa6 (patch)
tree9363e9e7b9c61162031127d28d1c1d4611d9d316
parent1ee0ae24ea0985589364a755d33b0159a8b0eee1 (diff)
DTC: Fix memory leak on flatname.
If flatname was not referenced by the "node" structure, the reference to the allocated string is lost at function exit. We need to free it if is not used by "node". Signed-off-by: Jean-Christophe Dubois <jcd@tribudubois.net> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
-rw-r--r--flattree.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/flattree.c b/flattree.c
index ec14954..089b976 100644
--- a/flattree.c
+++ b/flattree.c
@@ -797,6 +797,10 @@ static struct node *unflatten_tree(struct inbuf *dtbuf,
}
} while (val != FDT_END_NODE);
+ if (node->name != flatname) {
+ free(flatname);
+ }
+
return node;
}