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>

Michał Kępień committed Oct 20, 2020 at 08:48 UTC ec7967cfafd5844e33afbc1e6fb8ba1b9e5b111b
3 files changed +5
builtin/merge-tree.c
+1
@@ -109,6 +109,7 @@ static void show_diff(struct merge_list *entry)
109 xdemitconf_t xecfg;
110 xdemitcb_t ecb;
111
112 + memset(&xpp, 0, sizeof(xpp));
113 xpp.flags = 0;
114 memset(&xecfg, 0, sizeof(xecfg));
115 xecfg.ctxlen = 3;
xdiff/xhistogram.c
+2
@@ -235,6 +235,8 @@ static int fall_back_to_classic_diff(xpparam_t const *xpp, xdfenv_t *env,
235 int line1, int count1, int line2, int count2)
236 {
237 xpparam_t xpparam;
238 +
239 + memset(&xpparam, 0, sizeof(xpparam));
240 xpparam.flags = xpp->flags & ~XDF_DIFF_ALGORITHM_MASK;
241
242 return xdl_fall_back_diff(env, &xpparam,
xdiff/xpatience.c
+2
@@ -318,6 +318,8 @@ static int fall_back_to_classic_diff(struct hashmap *map,
318 int line1, int count1, int line2, int count2)
319 {
320 xpparam_t xpp;
321 +
322 + memset(&xpp, 0, sizeof(xpp));
323 xpp.flags = map->xpp->flags & ~XDF_DIFF_ALGORITHM_MASK;
324
325 return xdl_fall_back_diff(map->env, &xpp,