Skip to content

Commit cde0a05

Browse files
trastgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Thomas Rast <[email protected]> Reviewed-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent e9e03a7 commit cde0a05

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

commit-slab.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ static MAYBE_UNUSED elemtype *slabname## _at(struct slabname *s, \
9191
if (s->slab_count <= nth_slab) { \
9292
int i; \
9393
s->slab = xrealloc(s->slab, \
94-
(nth_slab + 1) * sizeof(s->slab)); \
94+
(nth_slab + 1) * sizeof(*s->slab)); \
9595
stat_ ##slabname## realloc++; \
9696
for (i = s->slab_count; i <= nth_slab; i++) \
9797
s->slab[i] = NULL; \

0 commit comments

Comments
 (0)