diff options
author | Jeff King <peff@peff.net> | 2014-06-18 22:02:13 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2014-06-19 21:25:17 +0200 |
commit | fa3f60b783b42e0d07c667a8f582c3df12791cec (patch) | |
tree | fab9253df02e858467cf98ede8c1bebfe75be11e /pack-revindex.h | |
parent | strbuf: add xstrfmt helper (diff) | |
download | git-fa3f60b783b42e0d07c667a8f582c3df12791cec.tar.xz git-fa3f60b783b42e0d07c667a8f582c3df12791cec.zip |
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 'pack-revindex.h')
0 files changed, 0 insertions, 0 deletions