Skip to content

[scudo] Fix c wrappers double free test. #148066

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 14, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion compiler-rt/lib/scudo/standalone/tests/wrappers_c_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,19 @@ TEST_F(ScudoWrappersCDeathTest, Malloc) {

free(P);
verifyDeallocHookPtr(P);
EXPECT_DEATH(free(P), "");

// Verify a double free causes an abort.
// Don't simply free(P) since EXPECT_DEATH will do a number of
// allocations before creating a new process. There is a possibility
// that the previously freed P is reused, therefore, in the new
// process doing free(P) is not a double free.
EXPECT_DEATH(
{
void *Ptr = malloc(Size);
free(Ptr);
free(Ptr);
},
"");

P = malloc(0U);
EXPECT_NE(P, nullptr);
Expand Down
Loading