From: Vitaly Buka Date: Thu, 3 Jun 2021 07:06:45 +0000 (-0700) Subject: [NFC][scudo] Avoid integer overflow in test X-Git-Tag: llvmorg-14-init~4997 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b40908e639b6075c77d7b2a990a2a273a39f4102;p=platform%2Fupstream%2Fllvm.git [NFC][scudo] Avoid integer overflow in test releasePagesToOS may shrink RSS below the value stored on start. --- diff --git a/compiler-rt/lib/scudo/standalone/tests/common_test.cpp b/compiler-rt/lib/scudo/standalone/tests/common_test.cpp index d8184a7..711e3b2 100644 --- a/compiler-rt/lib/scudo/standalone/tests/common_test.cpp +++ b/compiler-rt/lib/scudo/standalone/tests/common_test.cpp @@ -37,16 +37,16 @@ TEST(ScudoCommonTest, SKIP_ON_FUCHSIA(ResidentMemorySize)) { MapPlatformData Data = {}; void *P = map(nullptr, Size, "ResidentMemorySize", 0, &Data); ASSERT_NE(nullptr, P); - EXPECT_LT(getResidentMemorySize() - OnStart, Threshold); + EXPECT_LT(getResidentMemorySize(), OnStart + Threshold); memset(P, 1, Size); - EXPECT_GT(getResidentMemorySize() - OnStart, Size - Threshold); + EXPECT_GT(getResidentMemorySize(), OnStart + Size - Threshold); releasePagesToOS((uptr)P, 0, Size, &Data); - EXPECT_LT(getResidentMemorySize() - OnStart, Threshold); + EXPECT_LT(getResidentMemorySize(), OnStart + Threshold); memset(P, 1, Size); - EXPECT_GT(getResidentMemorySize() - OnStart, Size - Threshold); + EXPECT_GT(getResidentMemorySize(), OnStart + Size - Threshold); unmap(P, Size, 0, &Data); }