diff options
author | Philip Kelley <phkelley@microsoft.com> | 2020-05-10 21:43:38 -0700 |
---|---|---|
committer | Philip Kelley <phkelley@microsoft.com> | 2020-05-10 21:44:16 -0700 |
commit | 56c95cf6fb4c6af6ae4ec43460dad09159c4700d (patch) | |
tree | 29c80fc5da9f1de333e361c9e2f5ee58210cf536 | |
parent | d62e44cb8218840a0291fb5fbb7c5106e1e35a12 (diff) | |
download | libgit2-56c95cf6fb4c6af6ae4ec43460dad09159c4700d.tar.gz |
Fix uninitialized stack memory and NULL ptr dereference in stash_to_index
Caught by static analysis.
-rw-r--r-- | src/stash.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/stash.c b/src/stash.c index 4a13d0530..790f56fdd 100644 --- a/src/stash.c +++ b/src/stash.c @@ -173,7 +173,7 @@ static int stash_to_index( git_index *index, const char *path) { - git_index *repo_index; + git_index *repo_index = NULL; git_index_entry entry = {{0}}; struct stat st; int error; @@ -187,7 +187,7 @@ static int stash_to_index( return error; git_index_entry__init_from_stat(&entry, &st, - (repo_index != NULL || !repo_index->distrust_filemode)); + (repo_index == NULL || !repo_index->distrust_filemode)); entry.path = path; |