aboutsummaryrefslogtreecommitdiffstats
path: root/vespamalloc
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2021-06-29 12:47:51 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2021-06-29 14:55:04 +0000
commit871aafa29154576a8af6c16ff4182558d9df96a5 (patch)
tree40795dc1662bb350e613cefc16a29262a391b85c /vespamalloc
parent42167362fbeeed70c935c07a9020bba05a3f18f4 (diff)
Ensure errnoe is reset and saved in order to avoid sideeffects of later calls.
Diffstat (limited to 'vespamalloc')
-rw-r--r--vespamalloc/src/tests/test1/new_test.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/vespamalloc/src/tests/test1/new_test.cpp b/vespamalloc/src/tests/test1/new_test.cpp
index ac053323255..7988367f415 100644
--- a/vespamalloc/src/tests/test1/new_test.cpp
+++ b/vespamalloc/src/tests/test1/new_test.cpp
@@ -98,14 +98,18 @@ TEST("verify new with alignment = 64 with single element") {
#if __GLIBC_PREREQ(2, 26)
TEST("verify realloarray") {
void *arr = calloc(5,5);
+ errno = 0;
void *arr2 = reallocarray(arr, 800, 5);
+ int myErrno = errno;
EXPECT_NOT_EQUAL(arr, arr2);
EXPECT_NOT_EQUAL(nullptr, arr2);
- EXPECT_NOT_EQUAL(ENOMEM, errno);
+ EXPECT_NOT_EQUAL(ENOMEM, myErrno);
- void *arr3 = reallocarray(arr2, 1u << 33, 1u << 33);
+ errno = 0;
+ void *arr3 = reallocarray(arr2, 1ul << 33, 1ul << 33);
+ myErrno = errno;
EXPECT_EQUAL(nullptr, arr3);
- EXPECT_EQUAL(ENOMEM, errno);
+ EXPECT_EQUAL(ENOMEM, myErrno);
}
#endif