diff options
| author | lhchavez <lhchavez@lhchavez.com> | 2019-02-16 20:26:17 +0000 |
|---|---|---|
| committer | lhchavez <lhchavez@lhchavez.com> | 2019-02-16 20:27:48 +0000 |
| commit | 6e0dfc6ffab5b7ed02a2d7583f2f5f0758ecb8a8 (patch) | |
| tree | 78488b6839220e7fea934e77a295cc15aca4bf64 /src/stdalloc.c | |
| parent | bda0839734bad8351e1dbc9c7beb8ae1f00d831e (diff) | |
| download | libgit2-6e0dfc6ffab5b7ed02a2d7583f2f5f0758ecb8a8.tar.gz | |
Make stdalloc__reallocarray call stdalloc__realloc
This change avoids calling realloc(3) in more than one place.
Diffstat (limited to 'src/stdalloc.c')
| -rw-r--r-- | src/stdalloc.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/src/stdalloc.c b/src/stdalloc.c index c6d4ec80c..c4938e32b 100644 --- a/src/stdalloc.c +++ b/src/stdalloc.c @@ -88,11 +88,10 @@ static void *stdalloc__reallocarray(void *ptr, size_t nelem, size_t elsize, cons { size_t newsize; - GIT_UNUSED(file); - GIT_UNUSED(line); + if (GIT_MULTIPLY_SIZET_OVERFLOW(&newsize, nelem, elsize)) + return NULL; - return GIT_MULTIPLY_SIZET_OVERFLOW(&newsize, nelem, elsize) ? - NULL : realloc(ptr, newsize); + return stdalloc__realloc(ptr, newsize, file, line); } static void *stdalloc__mallocarray(size_t nelem, size_t elsize, const char *file, int line) |
