summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@microsoft.com>2015-09-28 16:24:50 -0400
committerEdward Thomson <ethomson@microsoft.com>2015-10-01 09:53:09 -0400
commitf362a1b1a7f5db83c02fffabafb68fa7ac64eb44 (patch)
treea6529a9cc30087ba1ba0fe3d3f7e784132d33cc1
parent2de198b4cec26c2b54c06da4baf88b3f57b9ca86 (diff)
downloadlibgit2-f362a1b1a7f5db83c02fffabafb68fa7ac64eb44.tar.gz
GITERR_CHECK_ALLOC_ADDn: multi-arg adders
-rw-r--r--src/common.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/common.h b/src/common.h
index cdb0b514d..9056deaae 100644
--- a/src/common.h
+++ b/src/common.h
@@ -199,6 +199,15 @@ GIT_INLINE(void) git__init_structure(void *structure, size_t len, unsigned int v
#define GITERR_CHECK_ALLOC_ADD(out, one, two) \
if (GIT_ADD_SIZET_OVERFLOW(out, one, two)) { return -1; }
+#define GITERR_CHECK_ALLOC_ADD3(out, one, two, three) \
+ if (GIT_ADD_SIZET_OVERFLOW(out, one, two) || \
+ GIT_ADD_SIZET_OVERFLOW(out, *(out), three)) { return -1; }
+
+#define GITERR_CHECK_ALLOC_ADD4(out, one, two, three, four) \
+ if (GIT_ADD_SIZET_OVERFLOW(out, one, two) || \
+ GIT_ADD_SIZET_OVERFLOW(out, *(out), three) || \
+ GIT_ADD_SIZET_OVERFLOW(out, *(out), four)) { return -1; }
+
/** Check for multiplicative overflow, failing if it would occur. */
#define GITERR_CHECK_ALLOC_MULTIPLY(out, nelem, elsize) \
if (GIT_MULTIPLY_SIZET_OVERFLOW(out, nelem, elsize)) { return -1; }