[scudo] Make Ptr volatile so that the malloc and free calls are not optimized out (#149944)

This fixes the test failure seen in the discussion about
https://github.com/llvm/llvm-project/pull/148066.
This commit is contained in:
Fabio D'Urso 2025-07-22 03:31:35 +02:00 committed by GitHub
parent 6752369139
commit fcdcc4ea7a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -183,7 +183,8 @@ TEST_F(ScudoWrappersCDeathTest, Malloc) {
// process doing free(P) is not a double free.
EXPECT_DEATH(
{
void *Ptr = malloc(Size);
// Note: volatile here prevents the calls from being optimized out.
void *volatile Ptr = malloc(Size);
free(Ptr);
free(Ptr);
},