summaryrefslogtreecommitdiffstats
path: root/http-backend.c
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2015-09-24 23:05:57 +0200
committerJunio C Hamano <gitster@pobox.com>2015-09-25 19:18:18 +0200
commit3131977de1476185209d4d56a0494f5b30ee5557 (patch)
treec78667db915c3fcb1add2b73c20fcc6e47a6a90f /http-backend.c
parenttrace: use strbuf for quote_crnl output (diff)
downloadgit-3131977de1476185209d4d56a0494f5b30ee5557.tar.xz
git-3131977de1476185209d4d56a0494f5b30ee5557.zip
progress: store throughput display in a strbuf
Coverity noticed that we strncpy() into a fixed-size buffer without making sure that it actually ended up NUL-terminated. This is unlikely to be a bug in practice, since throughput strings rarely hit 32 characters, but it would be nice to clean it up. The most obvious way to do so is to add a NUL-terminator. But instead, this patch switches the fixed-size buffer out for a strbuf. At first glance this seems much less efficient, until we realize that filling in the fixed-size buffer is done by writing into a strbuf and copying the result! By writing straight to the buffer, we actually end up more efficient: 1. We avoid an extra copy of the bytes. 2. Rather than malloc/free each time progress is shown, we can strbuf_reset and use the same buffer each time. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to '')
0 files changed, 0 insertions, 0 deletions