public inbox for git@vger.kernel.org 
 help / color / mirror / Atom feed
* [PATCH] Terminate argv with NULL before calling setup_revisions()
@ 2009-05-21  9:32 Nguyễn Thái Ngọc Duy
  0 siblings, 0 replies; only message in thread
From: Nguyễn Thái Ngọc Duy @ 2009-05-21  9:32 UTC (permalink / raw)
  To: git, Junio C Hamano, Johannes Sixt; +Cc: Nguyễn Thái Ngọc Duy

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>
---
 bundle.c    |    2 +-
 http-push.c |    3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/bundle.c b/bundle.c
index d0dd818..e4b2aa9 100644
--- a/bundle.c
+++ b/bundle.c
@@ -98,7 +98,7 @@ int verify_bundle(struct bundle_header *header, int verbose)
 	 */
 	struct ref_list *p = &header->prerequisites;
 	struct rev_info revs;
-	const char *argv[] = {NULL, "--all"};
+	const char *argv[] = {NULL, "--all", NULL};
 	struct object_array refs;
 	struct commit *commit;
 	int i, ret = 0, req_nr;
diff --git a/http-push.c b/http-push.c
index 29e8ebf..dac2c6e 100644
--- a/http-push.c
+++ b/http-push.c
@@ -2326,7 +2326,7 @@ int main(int argc, char **argv)
 	new_refs = 0;
 	for (ref = remote_refs; ref; ref = ref->next) {
 		char old_hex[60], *new_hex;
-		const char *commit_argv[4];
+		const char *commit_argv[5];
 		int commit_argc;
 		char *new_sha1_hex, *old_sha1_hex;
 
@@ -2406,6 +2406,7 @@ int main(int argc, char **argv)
 			commit_argv[3] = old_sha1_hex;
 			commit_argc++;
 		}
+		commit_argv[commit_argc] = NULL;
 		init_revisions(&revs, setup_git_directory());
 		setup_revisions(commit_argc, commit_argv, &revs, NULL);
 		revs.edge_hint = 0; /* just in case */
-- 
test

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2009-05-21  9:33 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-05-21  9:32 [PATCH] Terminate argv with NULL before calling setup_revisions() Nguyễn Thái Ngọc Duy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox