Skip to content

Commit d6d2f23

Browse files
peffgitster
authored andcommitted
combine-diff: zero memory used for callback filepairs
In commit 25e5e2b (combine-diff: support format_callback, 2011-08-19), the combined-diff code learned how to make a multi-sourced `diff_filepair` to pass to a diff callback. When we create each filepair, we do not bother to fill in many of the fields, because they would make no sense (e.g. there can be no rename score or broken_pair flag because we do not go through the diffcore filters). However, we did not even bother to zero them, leading to random values. Let's make sure everything is blank with xcalloc(), just as the regular diff code does. We would potentially want to set the `status` flag to something non-zero, but it is not clear to what. Possibly a new DIFF_STATUS_COMBINED would make sense, as this is not strictly a modification, nor does it fit any other category. Since it is not yet clear what callers would want, this patch simply leaves it as `0`, the same empty flag that is seen when `diffcore_std` is not used at all. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Toon Claes <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 16bd9f2 commit d6d2f23

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

combine-diff.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1315,7 +1315,7 @@ static struct diff_filepair *combined_pair(struct combine_diff_path *p,
13151315
struct diff_filepair *pair;
13161316
struct diff_filespec *pool;
13171317

1318-
pair = xmalloc(sizeof(*pair));
1318+
CALLOC_ARRAY(pair, 1);
13191319
CALLOC_ARRAY(pool, st_add(num_parent, 1));
13201320
pair->one = pool + 1;
13211321
pair->two = pool;

0 commit comments

Comments
 (0)