From 9e76d22ab561e496122ffcf6ad00f6d32b793d7e Mon Sep 17 00:00:00 2001 From: Tor Egge Date: Wed, 30 Jun 2021 15:58:56 +0200 Subject: Proxy call to reallocarray to avoid compile time overflow detection. --- vespamalloc/src/tests/test1/new_test.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'vespamalloc') diff --git a/vespamalloc/src/tests/test1/new_test.cpp b/vespamalloc/src/tests/test1/new_test.cpp index 653f039bccd..a82badbbbdc 100644 --- a/vespamalloc/src/tests/test1/new_test.cpp +++ b/vespamalloc/src/tests/test1/new_test.cpp @@ -3,6 +3,7 @@ #include #include #include +#include LOG_SETUP("new_test"); @@ -96,7 +97,8 @@ TEST("verify new with alignment = 64 with single element") { } #if __GLIBC_PREREQ(2, 26) -TEST("verify realloarray") { +TEST("verify reallocarray") { + std::function call_reallocarray = [](void *ptr, size_t nmemb, size_t size) noexcept { return reallocarray(ptr, nmemb, size); }; void *arr = calloc(5,5); //Used to ensure that 'arr' can not resized in place. std::vector> dummies; @@ -104,14 +106,14 @@ TEST("verify realloarray") { dummies.push_back(std::make_unique(5*5)); } errno = 0; - void *arr2 = reallocarray(arr, 800, 5); + void *arr2 = call_reallocarray(arr, 800, 5); int myErrno = errno; EXPECT_NOT_EQUAL(arr, arr2); EXPECT_NOT_EQUAL(nullptr, arr2); EXPECT_NOT_EQUAL(ENOMEM, myErrno); errno = 0; - void *arr3 = reallocarray(arr2, 1ul << 33, 1ul << 33); + void *arr3 = call_reallocarray(arr2, 1ul << 33, 1ul << 33); myErrno = errno; EXPECT_EQUAL(nullptr, arr3); EXPECT_EQUAL(ENOMEM, myErrno); -- cgit v1.2.3