summaryrefslogtreecommitdiff
path: root/src/diff_driver.c
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@microsoft.com>2015-02-12 12:19:37 -0500
committerEdward Thomson <ethomson@microsoft.com>2015-02-13 09:27:33 -0500
commitf1453c59b2afb9dab43281bfe9f1ba34cf6e0d02 (patch)
treecb189e211547042080f35227b7e4d3f9b0c8ac2a /src/diff_driver.c
parent650e45f69124bd8b53ecefddeb214a82538ab2c1 (diff)
downloadlibgit2-f1453c59b2afb9dab43281bfe9f1ba34cf6e0d02.tar.gz
Make our overflow check look more like gcc/clang's
Make our overflow checking look more like gcc and clang's, so that we can substitute it out with the compiler instrinsics on platforms that support it. This means dropping the ability to pass `NULL` as an out parameter. As a result, the macros also get updated to reflect this as well.
Diffstat (limited to 'src/diff_driver.c')
-rw-r--r--src/diff_driver.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/diff_driver.c b/src/diff_driver.c
index 67f1c591d..e4d9a0699 100644
--- a/src/diff_driver.c
+++ b/src/diff_driver.c
@@ -163,12 +163,13 @@ static int diff_driver_alloc(
{
git_diff_driver *driver;
size_t driverlen = sizeof(git_diff_driver),
- namelen = strlen(name);
+ namelen = strlen(name),
+ alloclen;
- GITERR_CHECK_ALLOC_ADD(driverlen, namelen);
- GITERR_CHECK_ALLOC_ADD(driverlen + namelen, 1);
+ GITERR_CHECK_ALLOC_ADD(&alloclen, driverlen, namelen);
+ GITERR_CHECK_ALLOC_ADD(&alloclen, alloclen, 1);
- driver = git__calloc(1, driverlen + namelen + 1);
+ driver = git__calloc(1, alloclen);
GITERR_CHECK_ALLOC(driver);
memcpy(driver->name, name, namelen);