提交 cde0a057 编写于 作者: T Thomas Rast 提交者: Junio C Hamano

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: NNguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: NThomas Rast <tr@thomasrast.ch>
Reviewed-by: NJeff King <peff@peff.net>
Signed-off-by: NJunio C Hamano <gitster@pobox.com>
上级 e9e03a77
......@@ -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; \
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册