summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLucas De Marchi <lucas.demarchi@intel.com>2015-02-26 03:38:52 -0300
committerLucas De Marchi <lucas.demarchi@intel.com>2015-02-26 03:40:47 -0300
commita1bec0dfdb53774fbc9e0f082a85562a5a9b02e2 (patch)
tree0a53da6e49f371ff852394bd8e7dca2c5c8c18d0
parent0bcdef97009a99fb9ef8426e3fef72b69f0dd156 (diff)
downloadkmod-a1bec0dfdb53774fbc9e0f082a85562a5a9b02e2.tar.gz
depmod: fix leak in case of malloc(0)
malloc(0) can return != NULL. We need to pass the pointer to free(). This happens if index__haschildren(node) returned true, but child_count is set to 0.
-rw-r--r--tools/depmod.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/tools/depmod.c b/tools/depmod.c
index afde322..851af0c 100644
--- a/tools/depmod.c
+++ b/tools/depmod.c
@@ -367,10 +367,11 @@ static uint32_t index_write__node(const struct index_node *node, FILE *out)
fputc(node->first, out);
fputc(node->last, out);
fwrite(child_offs, sizeof(uint32_t), child_count, out);
- free(child_offs);
offset |= INDEX_NODE_CHILDS;
}
+ free(child_offs);
+
if (node->values) {
const struct index_value *v;
unsigned int value_count;