From cde0a0576c8950599ef11184bc35aea648f7e717 Mon Sep 17 00:00:00 2001 From: Thomas Rast Date: Sun, 1 Dec 2013 21:41:55 +0100 Subject: [PATCH] commit-slab: sizeof() the right type in xrealloc MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Signed-off-by: Thomas Rast Reviewed-by: Jeff King Signed-off-by: Junio C Hamano --- commit-slab.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commit-slab.h b/commit-slab.h index d068e2d531..cc114b53b0 100644 --- a/commit-slab.h +++ b/commit-slab.h @@ -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; \