Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f362a1b

Browse files
author
Edward Thomson
committed
GITERR_CHECK_ALLOC_ADDn: multi-arg adders
1 parent 2de198b commit f362a1b

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/common.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,15 @@ GIT_INLINE(void) git__init_structure(void *structure, size_t len, unsigned int v
199199
#define GITERR_CHECK_ALLOC_ADD(out, one, two) \
200200
if (GIT_ADD_SIZET_OVERFLOW(out, one, two)) { return -1; }
201201

202+
#define GITERR_CHECK_ALLOC_ADD3(out, one, two, three) \
203+
if (GIT_ADD_SIZET_OVERFLOW(out, one, two) || \
204+
GIT_ADD_SIZET_OVERFLOW(out, *(out), three)) { return -1; }
205+
206+
#define GITERR_CHECK_ALLOC_ADD4(out, one, two, three, four) \
207+
if (GIT_ADD_SIZET_OVERFLOW(out, one, two) || \
208+
GIT_ADD_SIZET_OVERFLOW(out, *(out), three) || \
209+
GIT_ADD_SIZET_OVERFLOW(out, *(out), four)) { return -1; }
210+
202211
/** Check for multiplicative overflow, failing if it would occur. */
203212
#define GITERR_CHECK_ALLOC_MULTIPLY(out, nelem, elsize) \
204213
if (GIT_MULTIPLY_SIZET_OVERFLOW(out, nelem, elsize)) { return -1; }

0 commit comments

Comments
 (0)