diff options
author | Matt Burke <spraints@gmail.com> | 2015-09-10 14:16:39 -0400 |
---|---|---|
committer | Matt Burke <spraints@gmail.com> | 2015-09-10 14:16:39 -0400 |
commit | d29c5412aa91b279b1b2db4fe57dd6fe71272b91 (patch) | |
tree | e99258ac971593acc147d73b6c4bc4c183f9cea3 /src/remote.c | |
parent | 3245896bb7527cb42d48faf68f33858c887f2b3d (diff) | |
download | libgit2-d29c5412aa91b279b1b2db4fe57dd6fe71272b91.tar.gz |
Avoid segfault when opts == NULL
Diffstat (limited to 'src/remote.c')
-rw-r--r-- | src/remote.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/remote.c b/src/remote.c index a374a84b3..ce6e13b3d 100644 --- a/src/remote.c +++ b/src/remote.c @@ -2392,14 +2392,17 @@ int git_remote_upload(git_remote *remote, const git_strarray *refspecs, const gi git_push *push; git_refspec *spec; const git_remote_callbacks *cbs = NULL; + const git_strarray *custom_headers = NULL; assert(remote); - if (opts) + if (opts) { cbs = &opts->callbacks; + custom_headers = &opts->custom_headers; + } if (!git_remote_connected(remote) && - (error = git_remote_connect(remote, GIT_DIRECTION_PUSH, cbs, &opts->custom_headers)) < 0) + (error = git_remote_connect(remote, GIT_DIRECTION_PUSH, cbs, custom_headers)) < 0) goto cleanup; free_refspecs(&remote->active_refspecs); @@ -2448,15 +2451,17 @@ int git_remote_push(git_remote *remote, const git_strarray *refspecs, const git_ { int error; const git_remote_callbacks *cbs = NULL; + const git_strarray *custom_headers = NULL; if (opts) { GITERR_CHECK_VERSION(&opts->callbacks, GIT_REMOTE_CALLBACKS_VERSION, "git_remote_callbacks"); cbs = &opts->callbacks; + custom_headers = &opts->custom_headers; } assert(remote && refspecs); - if ((error = git_remote_connect(remote, GIT_DIRECTION_PUSH, cbs, &opts->custom_headers)) < 0) + if ((error = git_remote_connect(remote, GIT_DIRECTION_PUSH, cbs, custom_headers)) < 0) return error; if ((error = git_remote_upload(remote, refspecs, opts)) < 0) |