summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 2c5b011)
raw | patch | inline | side by side (parent: 2c5b011)
author | Jeff King <peff@peff.net> | |
Fri, 8 May 2009 09:06:15 +0000 (05:06 -0400) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Sat, 9 May 2009 08:39:40 +0000 (01:39 -0700) |
The alias argv comes from the split_cmdline function, which
splits the config text for the alias into an array of
strings. It returns the number of elements in the array, but
does not actually put a NULL at the end of the array.
Later, the trace function tries to print this argv and
assumes that it has the trailing NULL.
The split_cmdline function is probably at fault, since argv
lists almost always end with a NULL signal. This patch adds
one, in addition to the returned count; this doesn't hurt
the other callers at all, since they were presumably using
the count already (and will never look at the NULL).
While we're there and using ALLOC_GROW, let's clean up the
other manual grow.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
splits the config text for the alias into an array of
strings. It returns the number of elements in the array, but
does not actually put a NULL at the end of the array.
Later, the trace function tries to print this argv and
assumes that it has the trailing NULL.
The split_cmdline function is probably at fault, since argv
lists almost always end with a NULL signal. This patch adds
one, in addition to the returned count; this doesn't hurt
the other callers at all, since they were presumably using
the count already (and will never look at the NULL).
While we're there and using ALLOC_GROW, let's clean up the
other manual grow.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
alias.c | patch | blob | history |
index ccb1108c94436035d0da8b1d6f08f859b68294a3..4f4d0141cdca47cc2fd5062624e3a7b643d0793c 100644 (file)
--- a/alias.c
+++ b/alias.c
while (cmdline[++src]
&& isspace(cmdline[src]))
; /* skip */
- if (count >= size) {
- size += 16;
- *argv = xrealloc(*argv, sizeof(char*) * size);
- }
+ ALLOC_GROW(*argv, count+1, size);
(*argv)[count++] = cmdline + dst;
} else if (!quoted && (c == '\'' || c == '"')) {
quoted = c;
return error("unclosed quote");
}
+ ALLOC_GROW(*argv, count+1, size);
+ (*argv)[count] = NULL;
+
return count;
}