From a1bec0dfdb53774fbc9e0f082a85562a5a9b02e2 Mon Sep 17 00:00:00 2001 From: Lucas De Marchi Date: Thu, 26 Feb 2015 03:38:52 -0300 Subject: [PATCH] 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. --- tools/depmod.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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; -- 2.39.2