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 <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Nguyễn Thái Ngọc Duy committed
May 21, 2009 at 19:32 UTC
a80aad7b85fc560451e07792d64ab6cb15a39914
2 files changed
+3
-2
bundle.c
+1
-1
@@ -98,7 +98,7 @@ int verify_bundle(struct bundle_header *header, int verbose)
98
*/
99
struct ref_list *p = &header->prerequisites;
100
struct rev_info revs;
101
- const char *argv[] = {NULL, "--all"};
101
+ const char *argv[] = {NULL, "--all", NULL};
102
struct object_array refs;
103
struct commit *commit;
104
int i, ret = 0, req_nr;
http-push.c
+2
-1
@@ -2326,7 +2326,7 @@ int main(int argc, char **argv)
2326
new_refs = 0;
2327
for (ref = remote_refs; ref; ref = ref->next) {
2328
char old_hex[60], *new_hex;
2329
- const char *commit_argv[4];
2329
+ const char *commit_argv[5];
2330
int commit_argc;
2331
char *new_sha1_hex, *old_sha1_hex;
2332
@@ -2406,6 +2406,7 @@ int main(int argc, char **argv)
2406
commit_argv[3] = old_sha1_hex;
2407
commit_argc++;
2408
}
2409
+ commit_argv[commit_argc] = NULL;
2410
init_revisions(&revs, setup_git_directory());
2411
setup_revisions(commit_argc, commit_argv, &revs, NULL);
2412
revs.edge_hint = 0; /* just in case */