Skip to content

Commit a80aad7

Browse files
pcloudsgitster
authored andcommitted
Terminate argv with NULL before calling setup_revisions()
It is convention that argv should be terminated with NULL, even if argc is used to specify the size of argv. setup_revisions() requires this and may segfault otherwise. This patch makes sure that all argv (that I can find) is NULL terminated. Signed-off-by: Nguyễn Thái Ngọc Duy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 06f3919 commit a80aad7

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

bundle.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ int verify_bundle(struct bundle_header *header, int verbose)
9898
*/
9999
struct ref_list *p = &header->prerequisites;
100100
struct rev_info revs;
101-
const char *argv[] = {NULL, "--all"};
101+
const char *argv[] = {NULL, "--all", NULL};
102102
struct object_array refs;
103103
struct commit *commit;
104104
int i, ret = 0, req_nr;

http-push.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2326,7 +2326,7 @@ int main(int argc, char **argv)
23262326
new_refs = 0;
23272327
for (ref = remote_refs; ref; ref = ref->next) {
23282328
char old_hex[60], *new_hex;
2329-
const char *commit_argv[4];
2329+
const char *commit_argv[5];
23302330
int commit_argc;
23312331
char *new_sha1_hex, *old_sha1_hex;
23322332

@@ -2406,6 +2406,7 @@ int main(int argc, char **argv)
24062406
commit_argv[3] = old_sha1_hex;
24072407
commit_argc++;
24082408
}
2409+
commit_argv[commit_argc] = NULL;
24092410
init_revisions(&revs, setup_git_directory());
24102411
setup_revisions(commit_argc, commit_argv, &revs, NULL);
24112412
revs.edge_hint = 0; /* just in case */

0 commit comments

Comments
 (0)