mirror of
https://github.com/git/git.git
synced 2024-11-27 12:03:55 +08:00
commit-slab: sizeof() the right type in xrealloc
When allocating the slab, the code accidentally computed the array size from s->slab (an elemtype**). The slab is an array of elemtype*, however, so we should take the size of *s->slab. Noticed-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Thomas Rast <tr@thomasrast.ch> Reviewed-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
e9e03a7799
commit
cde0a0576c
@ -91,7 +91,7 @@ static MAYBE_UNUSED elemtype *slabname## _at(struct slabname *s, \
|
||||
if (s->slab_count <= nth_slab) { \
|
||||
int i; \
|
||||
s->slab = xrealloc(s->slab, \
|
||||
(nth_slab + 1) * sizeof(s->slab)); \
|
||||
(nth_slab + 1) * sizeof(*s->slab)); \
|
||||
stat_ ##slabname## realloc++; \
|
||||
for (i = s->slab_count; i <= nth_slab; i++) \
|
||||
s->slab[i] = NULL; \
|
||||
|
Loading…
Reference in New Issue
Block a user