{"thread":{"id":"55709","subject":"[PATCH] sparse-index: fix uninitialized jump","startedAt":"2021-05-17T12:22:22Z","lastAt":"2021-05-17T21:46:04Z","messageCount":2,"participants":["Derrick Stolee via GitGitGadget","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"424727","messageId":"pull.953.git.1621254137590.gitgitgadget@gmail.com","threadId":"55709","inReplyTo":null,"subject":"[PATCH] sparse-index: fix uninitialized jump","fromName":"Derrick Stolee via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2021-05-17T12:22:17Z","receivedAt":"2021-05-17T12:22:22Z","isPatch":true,"sender":{"key":"stolee@gmail.com","avatar":"https://avatars.githubusercontent.com/u/570044?v=4"},"body":"From: Derrick Stolee <dstolee@microsoft.com>\n\nWhile testing the sparse-index, I verified a test with --valgrind and it\ncomplained about an uninitialized value being used in a jump in the\npath_matches_pattern_list() method. The line was this one:\n\n\tif (*dtype == DT_UNKNOWN)\n\nIn the call stack, the culprit was the initialization of the dtype\nvariable in convert_to_sparse_rec().\n\nSigned-off-by: Derrick Stolee <dstolee@microsoft.com>\n---\n    Sparse-index: fix uninitialized variable\n    \n    I noticed this by accident while using --valgrind for a different\n    reason. Seems like an easy fix.\n    \n    Thanks, -Stolee\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-953%2Fderrickstolee%2Fsparse-index%2Funinitialized-v1\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-953/derrickstolee/sparse-index/uninitialized-v1\nPull-Request: https://github.com/gitgitgadget/git/pull/953\n\n sparse-index.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/sparse-index.c b/sparse-index.c\nindex b0d5dc5f081b..affc4048f279 100644\n--- a/sparse-index.c\n+++ b/sparse-index.c\n@@ -34,7 +34,7 @@ static int convert_to_sparse_rec(struct index_state *istate,\n \tint i, can_convert = 1;\n \tint start_converted = num_converted;\n \tenum pattern_match_result match;\n-\tint dtype;\n+\tint dtype = DT_UNKNOWN;\n \tstruct strbuf child_path = STRBUF_INIT;\n \tstruct pattern_list *pl = istate->sparse_checkout_patterns;\n \n\nbase-commit: bf949ade81106fbda068c1fdb2c6fd1cb1babe7e\n-- \ngitgitgadget\n"},{"id":"424788","messageId":"xmqqo8d9590q.fsf@gitster.g","threadId":"55709","inReplyTo":"pull.953.git.1621254137590.gitgitgadget@gmail.com","subject":"Re: [PATCH] sparse-index: fix uninitialized jump","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2021-05-17T21:45:57Z","receivedAt":"2021-05-17T21:46:04Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Derrick Stolee via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n\n> From: Derrick Stolee <dstolee@microsoft.com>\n>\n> While testing the sparse-index, I verified a test with --valgrind and it\n> complained about an uninitialized value being used in a jump in the\n> path_matches_pattern_list() method. The line was this one:\n>\n> \tif (*dtype == DT_UNKNOWN)\n>\n> In the call stack, the culprit was the initialization of the dtype\n> variable in convert_to_sparse_rec().\n>\n> Signed-off-by: Derrick Stolee <dstolee@microsoft.com>\n> ---\n\nLooks good.\n\n> Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-953%2Fderrickstolee%2Fsparse-index%2Funinitialized-v1\n> Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-953/derrickstolee/sparse-index/uninitialized-v1\n> Pull-Request: https://github.com/gitgitgadget/git/pull/953\n>\n>  sparse-index.c | 2 +-\n>  1 file changed, 1 insertion(+), 1 deletion(-)\n>\n> diff --git a/sparse-index.c b/sparse-index.c\n> index b0d5dc5f081b..affc4048f279 100644\n> --- a/sparse-index.c\n> +++ b/sparse-index.c\n> @@ -34,7 +34,7 @@ static int convert_to_sparse_rec(struct index_state *istate,\n>  \tint i, can_convert = 1;\n>  \tint start_converted = num_converted;\n>  \tenum pattern_match_result match;\n> -\tint dtype;\n> +\tint dtype = DT_UNKNOWN;\n>  \tstruct strbuf child_path = STRBUF_INIT;\n>  \tstruct pattern_list *pl = istate->sparse_checkout_patterns;\n>  \n>\n> base-commit: bf949ade81106fbda068c1fdb2c6fd1cb1babe7e\n"}]}