Fix potential crash when saved_git_id is NULL

We have a safe strdup alternative. Let's just use it.

Fixes #2220

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2019-08-09 09:45:28 -07:00 committed by bstoeger
parent 7eadc8ef7e
commit e9194a5c40

View file

@ -264,7 +264,7 @@ int check_git_sha(const char *filename, struct git_repository **git_p, const cha
struct git_repository *git;
const char *branch = NULL;
char *current_sha = strdup(saved_git_id);
char *current_sha = copy_string(saved_git_id);
git = is_git_repository(filename, &branch, NULL, false);
if (git_p)
*git_p = git;