Skip to content

Commit d29c541

Browse files
committed
Avoid segfault when opts == NULL
1 parent 3245896 commit d29c541

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

src/remote.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2392,14 +2392,17 @@ int git_remote_upload(git_remote *remote, const git_strarray *refspecs, const gi
23922392
git_push *push;
23932393
git_refspec *spec;
23942394
const git_remote_callbacks *cbs = NULL;
2395+
const git_strarray *custom_headers = NULL;
23952396

23962397
assert(remote);
23972398

2398-
if (opts)
2399+
if (opts) {
23992400
cbs = &opts->callbacks;
2401+
custom_headers = &opts->custom_headers;
2402+
}
24002403

24012404
if (!git_remote_connected(remote) &&
2402-
(error = git_remote_connect(remote, GIT_DIRECTION_PUSH, cbs, &opts->custom_headers)) < 0)
2405+
(error = git_remote_connect(remote, GIT_DIRECTION_PUSH, cbs, custom_headers)) < 0)
24032406
goto cleanup;
24042407

24052408
free_refspecs(&remote->active_refspecs);
@@ -2448,15 +2451,17 @@ int git_remote_push(git_remote *remote, const git_strarray *refspecs, const git_
24482451
{
24492452
int error;
24502453
const git_remote_callbacks *cbs = NULL;
2454+
const git_strarray *custom_headers = NULL;
24512455

24522456
if (opts) {
24532457
GITERR_CHECK_VERSION(&opts->callbacks, GIT_REMOTE_CALLBACKS_VERSION, "git_remote_callbacks");
24542458
cbs = &opts->callbacks;
2459+
custom_headers = &opts->custom_headers;
24552460
}
24562461

24572462
assert(remote && refspecs);
24582463

2459-
if ((error = git_remote_connect(remote, GIT_DIRECTION_PUSH, cbs, &opts->custom_headers)) < 0)
2464+
if ((error = git_remote_connect(remote, GIT_DIRECTION_PUSH, cbs, custom_headers)) < 0)
24602465
return error;
24612466

24622467
if ((error = git_remote_upload(remote, refspecs, opts)) < 0)

0 commit comments

Comments
 (0)