diff options
author | Jeff King <peff@peff.net> | 2014-06-18 16:02:13 -0400 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2014-06-19 12:25:17 -0700 |
commit | fa3f60b783b42e0d07c667a8f582c3df12791cec (patch) | |
tree | fab9253df02e858467cf98ede8c1bebfe75be11e /builtin/fetch.c | |
parent | strbuf: add xstrfmt helper (diff) | |
download | tgif-fa3f60b783b42e0d07c667a8f582c3df12791cec.tar.xz |
use xstrfmt in favor of manual size calculations
In many parts of the code, we do an ugly and error-prone
malloc like:
const char *fmt = "something %s";
buf = xmalloc(strlen(foo) + 10 + 1);
sprintf(buf, fmt, foo);
This makes the code brittle, and if we ever get the
allocation wrong, is a potential heap overflow. Let's
instead favor xstrfmt, which handles the allocation
automatically, and makes the code shorter and more readable.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/fetch.c')
0 files changed, 0 insertions, 0 deletions