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:
Thomas Rast 2013-12-01 21:41:55 +01:00 коммит произвёл Junio C Hamano
Родитель e9e03a7799
Коммит cde0a0576c
1 изменённых файлов: 1 добавлений и 1 удалений

Просмотреть файл

@ -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; \