[PATCH] ui-patch: fix segfault when a path prefix is passed

Eric Wong normalperson at yhbt.net
Sun Jan 22 23:30:30 CET 2017


From: Eric Wong <e at 80x24.org>

pathspec.c::parse_pathspec in git assumes the `argv' array
is terminated with a NULL entry, so do not let it iterate
past the end of the array.

Signed-off-by: Eric Wong <e at 80x24.org>
---
 ui-patch.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ui-patch.c b/ui-patch.c
index ec7f352..53475f7 100644
--- a/ui-patch.c
+++ b/ui-patch.c
@@ -18,7 +18,7 @@ void cgit_print_patch(const char *new_rev, const char *old_rev,
 	struct commit *commit;
 	struct object_id new_rev_oid, old_rev_oid;
 	char rev_range[2 * 40 + 3];
-	const char *rev_argv[] = { NULL, "--reverse", "--format=email", rev_range, "--", prefix };
+	const char *rev_argv[] = { NULL, "--reverse", "--format=email", rev_range, "--", prefix, NULL };
 	int rev_argc = ARRAY_SIZE(rev_argv);
 	char *patchname;
 
-- 
EW


More information about the CGit mailing list