diff options
author | Jeff King <peff@peff.net> | 2019-04-11 13:48:14 (GMT) |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2019-04-12 04:34:17 (GMT) |
commit | 73a5faf0176548640784090190bb2448cf1708aa (patch) | |
tree | 8cd8928c8eacbd48f96173991077c0e7c5e461d6 /t/helper | |
parent | 0d0ac3826a3bbb9247e39e12623bbcfdd722f24c (diff) | |
download | git-73a5faf0176548640784090190bb2448cf1708aa.zip git-73a5faf0176548640784090190bb2448cf1708aa.tar.gz git-73a5faf0176548640784090190bb2448cf1708aa.tar.bz2 |
test-prio-queue: use xmalloc
test-prio-queue.c doesn't check the return value of malloc, and could
segfault.
It's unlikely for this to matter in practice; it's a small allocation,
and this code isn't even installed alongside the rest of Git. But let's
use xmalloc(), which makes auditing for other accidental uses of bare
malloc() easier.
Reported-by: 王健强 <jianqiang.wang@securitygossip.com>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/helper')
-rw-r--r-- | t/helper/test-prio-queue.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/t/helper/test-prio-queue.c b/t/helper/test-prio-queue.c index 5bc9c46..f402844 100644 --- a/t/helper/test-prio-queue.c +++ b/t/helper/test-prio-queue.c @@ -40,7 +40,7 @@ int cmd__prio_queue(int argc, const char **argv) } else if (!strcmp(*argv, "stack")) { pq.compare = NULL; } else { - int *v = malloc(sizeof(*v)); + int *v = xmalloc(sizeof(*v)); *v = atoi(*argv); prio_queue_put(&pq, v); } |