Skip to content

Commit b83bc6d

Browse files
authored
Merge pull request libgit2#5510 from phkelley/stash-to-index-crash
Fix uninitialized stack memory and NULL ptr dereference in stash_to_index
2 parents d62e44c + 56c95cf commit b83bc6d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/stash.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ static int stash_to_index(
173173
git_index *index,
174174
const char *path)
175175
{
176-
git_index *repo_index;
176+
git_index *repo_index = NULL;
177177
git_index_entry entry = {{0}};
178178
struct stat st;
179179
int error;
@@ -187,7 +187,7 @@ static int stash_to_index(
187187
return error;
188188

189189
git_index_entry__init_from_stat(&entry, &st,
190-
(repo_index != NULL || !repo_index->distrust_filemode));
190+
(repo_index == NULL || !repo_index->distrust_filemode));
191191

192192
entry.path = path;
193193

0 commit comments

Comments
 (0)