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>
Thomas Rast committed
Dec 1, 2013 at 21:41 UTC
cde0a0576c8950599ef11184bc35aea648f7e717
1 file changed
+1
-1
commit-slab.h
+1
-1
@@ -91,7 +91,7 @@ static MAYBE_UNUSED elemtype *slabname## _at(struct slabname *s, \
91
if (s->slab_count <= nth_slab) { \
92
int i; \
93
s->slab = xrealloc(s->slab, \
94
- (nth_slab + 1) * sizeof(s->slab)); \
94
+ (nth_slab + 1) * sizeof(*s->slab)); \
95
stat_ ##slabname## realloc++; \
96
for (i = s->slab_count; i <= nth_slab; i++) \
97
s->slab[i] = NULL; \