From: Lucas De Marchi Date: Thu, 26 Feb 2015 06:38:52 +0000 (-0300) Subject: depmod: fix leak in case of malloc(0) X-Git-Tag: v20~12 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a1bec0dfdb53774fbc9e0f082a85562a5a9b02e2;p=thirdparty%2Fkmod.git 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. --- diff --git a/tools/depmod.c b/tools/depmod.c index afde322b..851af0cc 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;