diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2021-06-29 12:47:51 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2021-06-29 12:47:51 +0000 |
commit | 10b889945e57bb3369bf75fd90a847ca69899a6e (patch) | |
tree | 44b11463e08b06aae8b73a63c35414a49f161ce2 /vespamalloc | |
parent | efe1bc39bad0169e7f508d227dd98790ea7a0780 (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.cpp | 10 |
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 |