]> git.ipfire.org Git - thirdparty/git.git/commitdiff
sparse-index: fix uninitialized jump
authorDerrick Stolee <dstolee@microsoft.com>
Mon, 17 May 2021 12:22:17 +0000 (12:22 +0000)
committerJunio C Hamano <gitster@pobox.com>
Mon, 17 May 2021 21:29:17 +0000 (06:29 +0900)
While testing the sparse-index, I verified a test with --valgrind and it
complained about an uninitialized value being used in a jump in the
path_matches_pattern_list() method. The line was this one:

if (*dtype == DT_UNKNOWN)

In the call stack, the culprit was the initialization of the dtype
variable in convert_to_sparse_rec().

Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
sparse-index.c

index 6f21397e2ee0911eb7ef40f2aaf33a363c078510..ca839e438172e93d16ffe30f0d4dc5a912e36a55 100644 (file)
@@ -34,7 +34,7 @@ static int convert_to_sparse_rec(struct index_state *istate,
        int i, can_convert = 1;
        int start_converted = num_converted;
        enum pattern_match_result match;
-       int dtype;
+       int dtype = DT_UNKNOWN;
        struct strbuf child_path = STRBUF_INIT;
        struct pattern_list *pl = istate->sparse_checkout_patterns;