summaryrefslogtreecommitdiff
path: root/commit-slab.h
diff options
context:
space:
mode:
authorThomas Rast <tr@thomasrast.ch>2013-12-01 20:41:55 (GMT)
committerJunio C Hamano <gitster@pobox.com>2013-12-02 20:46:01 (GMT)
commitcde0a0576c8950599ef11184bc35aea648f7e717 (patch)
tree53c952281c26148e9ff58d738d7ed01e293567a6 /commit-slab.h
parente9e03a77994f4bf030760e2644f718776de0eb39 (diff)
downloadgit-cde0a0576c8950599ef11184bc35aea648f7e717.zip
git-cde0a0576c8950599ef11184bc35aea648f7e717.tar.gz
git-cde0a0576c8950599ef11184bc35aea648f7e717.tar.bz2
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>
Diffstat (limited to 'commit-slab.h')
-rw-r--r--commit-slab.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/commit-slab.h b/commit-slab.h
index d068e2d..cc114b5 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; \