Bail out if remote->url would be NULL

This fixes a crash from attempting to invoke git__strdup() against NULL.
This commit is contained in:
Justin Spahr-Summers 2012-11-04 22:01:24 -08:00
parent 1e99ce9ac7
commit 83885891f5

View File

@ -132,6 +132,11 @@ int git_remote_load(git_remote **out, git_repository *repo, const char *name)
if ((error = git_config_get_string(&val, config, git_buf_cstr(&buf))) < 0) if ((error = git_config_get_string(&val, config, git_buf_cstr(&buf))) < 0)
goto cleanup; goto cleanup;
if (!val) {
error = -1;
goto cleanup;
}
remote->repo = repo; remote->repo = repo;
remote->url = git__strdup(val); remote->url = git__strdup(val);
GITERR_CHECK_ALLOC(remote->url); GITERR_CHECK_ALLOC(remote->url);