diff options
author | Junio C Hamano <gitster@pobox.com> | 2016-04-07 12:38:18 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2016-04-07 12:40:15 -0700 |
commit | 24041d6be54d89b5fb0b2bbf70df04bbbff6ba9e (patch) | |
tree | 9cfe7120b6ca7b97aac2542c99b5f95690c8812b /builtin/checkout.c | |
parent | replace trivial malloc + sprintf / strcpy calls with xstrfmt (diff) | |
download | tgif-24041d6be54d89b5fb0b2bbf70df04bbbff6ba9e.tar.xz |
setup.c: do not feed NULL to "%.*s" even with precision 0
A recent update 75faa45a (replace trivial malloc + sprintf / strcpy
calls with xstrfmt, 2015-09-24) rewrote
prepare an empty buffer
if (len)
append the first len bytes of "prefix" to the buffer
append "path" to the buffer
that computed "path", optionally prefixed by "prefix", into
xstrfmt("%.*s%s", len, prefix, path);
However, passing a NULL pointer to the printf(3) family of functions
to format it with %s conversion, even with the precision set to 0,
i.e.
xstrfmt("%.*s", 0, NULL)
yields undefined results, at least on some platforms.
Avoid this problem by substituting prefix with "" when len==0, as
prefix can legally be NULL in that case. This would mimick the
intent of the original code better.
Reported-by: Tom G. Christensen <tgc@jupiterrise.com>
Helped-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/checkout.c')
0 files changed, 0 insertions, 0 deletions