]> git.ipfire.org Git - thirdparty/git.git/commit - progress.c
progress: use xmalloc/xcalloc
authorJeff King <peff@peff.net>
Thu, 11 Apr 2019 13:49:57 +0000 (09:49 -0400)
committerJunio C Hamano <gitster@pobox.com>
Fri, 12 Apr 2019 04:34:17 +0000 (13:34 +0900)
commit999b951b285233d96904b1aad5e0dea22bed55c7
tree76a545535e180d69aee238070aaf70fee0a55b58
parent36c831972497c1141a704fb5ad179675111ee321
progress: use xmalloc/xcalloc

Since the early days of Git, the progress code allocates its struct with
a bare malloc(), not xmalloc(). If the allocation fails, we just avoid
showing progress at all.

While perhaps a noble goal not to fail the whole operation because of
optional progress, in practice:

  1. Any failure to allocate a few dozen bytes here means critical path
     allocations are likely to fail, too.

  2. These days we use a strbuf for throughput progress (and there's a
     patch under discussion to do the same for non-throughput cases,
     too). And that uses xmalloc() under the hood, which means we'd
     still die on some allocation failures.

Let's switch to xmalloc(). That makes us consistent with the rest of Git
and makes it easier to audit for other (less careful) bare mallocs.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
progress.c