Skip to content

Commit ec7967c

Browse files
kempniugitster
authored andcommitted
merge-base, xdiff: zero out xpparam_t structures
xpparam_t structures are usually zero-initialized before their specific fields are assigned to, but there are three locations in the tree where that does not happen. Add the missing memset() calls in order to make initialization of xpparam_t structures consistent tree-wide and to prevent stack garbage from being used as field values. Signed-off-by: Michał Kępień <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 47ae905 commit ec7967c

File tree

3 files changed

+5
-0
lines changed

3 files changed

+5
-0
lines changed

builtin/merge-tree.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ static void show_diff(struct merge_list *entry)
109109
xdemitconf_t xecfg;
110110
xdemitcb_t ecb;
111111

112+
memset(&xpp, 0, sizeof(xpp));
112113
xpp.flags = 0;
113114
memset(&xecfg, 0, sizeof(xecfg));
114115
xecfg.ctxlen = 3;

xdiff/xhistogram.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,8 @@ static int fall_back_to_classic_diff(xpparam_t const *xpp, xdfenv_t *env,
235235
int line1, int count1, int line2, int count2)
236236
{
237237
xpparam_t xpparam;
238+
239+
memset(&xpparam, 0, sizeof(xpparam));
238240
xpparam.flags = xpp->flags & ~XDF_DIFF_ALGORITHM_MASK;
239241

240242
return xdl_fall_back_diff(env, &xpparam,

xdiff/xpatience.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,8 @@ static int fall_back_to_classic_diff(struct hashmap *map,
318318
int line1, int count1, int line2, int count2)
319319
{
320320
xpparam_t xpp;
321+
322+
memset(&xpp, 0, sizeof(xpp));
321323
xpp.flags = map->xpp->flags & ~XDF_DIFF_ALGORITHM_MASK;
322324

323325
return xdl_fall_back_diff(map->env, &xpp,

0 commit comments

Comments
 (0)