Merge pull request #5510 from phkelley/stash-to-index-crash Fix uninitialized stack memory and NULL ptr dereference in stash_to_index
diff --git a/src/stash.c b/src/stash.c
index 4a13d05..790f56f 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;