diff options
author | Lucas De Marchi <lucas.demarchi@intel.com> | 2015-02-26 03:38:52 -0300 |
---|---|---|
committer | Lucas De Marchi <lucas.demarchi@intel.com> | 2015-02-26 03:40:47 -0300 |
commit | a1bec0dfdb53774fbc9e0f082a85562a5a9b02e2 (patch) | |
tree | 0a53da6e49f371ff852394bd8e7dca2c5c8c18d0 | |
parent | 0bcdef97009a99fb9ef8426e3fef72b69f0dd156 (diff) | |
download | kmod-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.c | 3 |
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; |