]> git.ipfire.org Git - thirdparty/git.git/commitdiff
merge-base, xdiff: zero out xpparam_t structures
authorMichał Kępień <michal@isc.org>
Tue, 20 Oct 2020 06:48:08 +0000 (08:48 +0200)
committerJunio C Hamano <gitster@pobox.com>
Tue, 20 Oct 2020 19:53:26 +0000 (12:53 -0700)
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>
builtin/merge-tree.c
xdiff/xhistogram.c
xdiff/xpatience.c

index e72714a5a87d02540f07fbbc65a86f66ed122cd8..de8520778d2ecdaa01dc23b513e24d187ef89d08 100644 (file)
@@ -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;
index c7b35a9667f322c151bc8de276654ecd38974aef..e694bfd9e31d54f1925a730a75b0ef6d9a4e6d95 100644 (file)
@@ -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,
index 3c5601b602a24cb6cd6e063466369b1a90a14f9f..20699a6f60547a88b5f07df0ab6651ccef5bff60 100644 (file)
@@ -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,