Skip to content

Commit d436146

Browse files
fabio-dtru
authored andcommitted
[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 #148066. (cherry picked from commit fcdcc4e)
1 parent 3b53c84 commit d436146

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

compiler-rt/lib/scudo/standalone/tests/wrappers_c_test.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,8 @@ TEST_F(ScudoWrappersCDeathTest, Malloc) {
183183
// process doing free(P) is not a double free.
184184
EXPECT_DEATH(
185185
{
186-
void *Ptr = malloc(Size);
186+
// Note: volatile here prevents the calls from being optimized out.
187+
void *volatile Ptr = malloc(Size);
187188
free(Ptr);
188189
free(Ptr);
189190
},

0 commit comments

Comments
 (0)