summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Kelley <phkelley@microsoft.com>2020-05-10 21:43:38 -0700
committerPhilip Kelley <phkelley@microsoft.com>2020-05-10 21:44:16 -0700
commit56c95cf6fb4c6af6ae4ec43460dad09159c4700d (patch)
tree29c80fc5da9f1de333e361c9e2f5ee58210cf536
parentd62e44cb8218840a0291fb5fbb7c5106e1e35a12 (diff)
downloadlibgit2-56c95cf6fb4c6af6ae4ec43460dad09159c4700d.tar.gz
Fix uninitialized stack memory and NULL ptr dereference in stash_to_index
Caught by static analysis.
-rw-r--r--src/stash.c4
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;