summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2014-11-17 12:12:41 -0800
committerJunio C Hamano <gitster@pobox.com>2014-11-17 13:34:07 -0800
commita16cc8b24710b7426468ac0dc3194170e6113385 (patch)
treea5349265d564945232362b38053fc17444139692
parenteeff891ac756fd97a05476446f15269b714ce4cc (diff)
downloadgit-jc/unpack-trees-plug-leak.tar.gz
unpack_trees: plug leakage of o->resultjc/unpack-trees-plug-leak
Most of the time the caller specifies to which destination variable the resulting index_state should be assigned by passing a non-NULL pointer in o->dst_index to receive that state, but for a caller that gives a NULL o->dst_index, the resulting index simply leaked. Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--unpack-trees.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/unpack-trees.c b/unpack-trees.c
index ad3e9a04fe..2515be6a60 100644
--- a/unpack-trees.c
+++ b/unpack-trees.c
@@ -1157,6 +1157,8 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options
if (o->dst_index) {
discard_index(o->dst_index);
*o->dst_index = o->result;
+ } else {
+ discard_index(&o->result);
}
done: