unpack_trees: plug leakage of o->result
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>
Junio C Hamano committed
Nov 17, 2014 at 12:12 UTC
a16cc8b24710b7426468ac0dc3194170e6113385
1 file changed
+2
unpack-trees.c
+2
@@ -1157,6 +1157,8 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options
1157
if (o->dst_index) {
1158
discard_index(o->dst_index);
1159
*o->dst_index = o->result;
1160
+ } else {
1161
+ discard_index(&o->result);
1162
}
1163
1164
done: