Skip to content

Commit 73a5faf

Browse files
peffgitster
authored andcommitted
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: 王健强 <[email protected]> Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 0d0ac38 commit 73a5faf

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

t/helper/test-prio-queue.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ int cmd__prio_queue(int argc, const char **argv)
4040
} else if (!strcmp(*argv, "stack")) {
4141
pq.compare = NULL;
4242
} else {
43-
int *v = malloc(sizeof(*v));
43+
int *v = xmalloc(sizeof(*v));
4444
*v = atoi(*argv);
4545
prio_queue_put(&pq, v);
4646
}

0 commit comments

Comments
 (0)