git@vger.kernel.org list mirror (unofficial, one of many)
 help / color / mirror / code / Atom feed
* [PATCH] sparse-index: fix uninitialized jump
@ 2021-05-17 12:22 Derrick Stolee via GitGitGadget
  2021-05-17 21:45 ` Junio C Hamano
  0 siblings, 1 reply; 2+ messages in thread
From: Derrick Stolee via GitGitGadget @ 2021-05-17 12:22 UTC (permalink / raw)
  To: git; +Cc: gitster, Derrick Stolee, Derrick Stolee

From: Derrick Stolee <dstolee@microsoft.com>

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>
---
    Sparse-index: fix uninitialized variable
    
    I noticed this by accident while using --valgrind for a different
    reason. Seems like an easy fix.
    
    Thanks, -Stolee

Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-953%2Fderrickstolee%2Fsparse-index%2Funinitialized-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-953/derrickstolee/sparse-index/uninitialized-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/953

 sparse-index.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sparse-index.c b/sparse-index.c
index b0d5dc5f081b..affc4048f279 100644
--- a/sparse-index.c
+++ b/sparse-index.c
@@ -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;
 

base-commit: bf949ade81106fbda068c1fdb2c6fd1cb1babe7e
-- 
gitgitgadget

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] sparse-index: fix uninitialized jump
  2021-05-17 12:22 [PATCH] sparse-index: fix uninitialized jump Derrick Stolee via GitGitGadget
@ 2021-05-17 21:45 ` Junio C Hamano
  0 siblings, 0 replies; 2+ messages in thread
From: Junio C Hamano @ 2021-05-17 21:45 UTC (permalink / raw)
  To: Derrick Stolee via GitGitGadget; +Cc: git, Derrick Stolee, Derrick Stolee

"Derrick Stolee via GitGitGadget" <gitgitgadget@gmail.com> writes:

> From: Derrick Stolee <dstolee@microsoft.com>
>
> 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>
> ---

Looks good.

> Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-953%2Fderrickstolee%2Fsparse-index%2Funinitialized-v1
> Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-953/derrickstolee/sparse-index/uninitialized-v1
> Pull-Request: https://github.com/gitgitgadget/git/pull/953
>
>  sparse-index.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/sparse-index.c b/sparse-index.c
> index b0d5dc5f081b..affc4048f279 100644
> --- a/sparse-index.c
> +++ b/sparse-index.c
> @@ -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;
>  
>
> base-commit: bf949ade81106fbda068c1fdb2c6fd1cb1babe7e

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-05-17 21:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-17 12:22 [PATCH] sparse-index: fix uninitialized jump Derrick Stolee via GitGitGadget
2021-05-17 21:45 ` Junio C Hamano

Code repositories for project(s) associated with this inbox:

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).