Browse Source

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ń <michal@isc.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
maint
Michał Kępień 4 years ago committed by Junio C Hamano
parent
commit
ec7967cfaf
  1. 1
      builtin/merge-tree.c
  2. 2
      xdiff/xhistogram.c
  3. 2
      xdiff/xpatience.c

1
builtin/merge-tree.c

@ -109,6 +109,7 @@ static void show_diff(struct merge_list *entry) @@ -109,6 +109,7 @@ static void show_diff(struct merge_list *entry)
xdemitconf_t xecfg;
xdemitcb_t ecb;

memset(&xpp, 0, sizeof(xpp));
xpp.flags = 0;
memset(&xecfg, 0, sizeof(xecfg));
xecfg.ctxlen = 3;

2
xdiff/xhistogram.c

@ -235,6 +235,8 @@ static int fall_back_to_classic_diff(xpparam_t const *xpp, xdfenv_t *env, @@ -235,6 +235,8 @@ static int fall_back_to_classic_diff(xpparam_t const *xpp, xdfenv_t *env,
int line1, int count1, int line2, int count2)
{
xpparam_t xpparam;

memset(&xpparam, 0, sizeof(xpparam));
xpparam.flags = xpp->flags & ~XDF_DIFF_ALGORITHM_MASK;

return xdl_fall_back_diff(env, &xpparam,

2
xdiff/xpatience.c

@ -318,6 +318,8 @@ static int fall_back_to_classic_diff(struct hashmap *map, @@ -318,6 +318,8 @@ static int fall_back_to_classic_diff(struct hashmap *map,
int line1, int count1, int line2, int count2)
{
xpparam_t xpp;

memset(&xpp, 0, sizeof(xpp));
xpp.flags = map->xpp->flags & ~XDF_DIFF_ALGORITHM_MASK;

return xdl_fall_back_diff(map->env, &xpp,

Loading…
Cancel
Save