crash: Fix typo in check logic

The remainder of the code assumes that the mmap was successful,
so the 'unexpected error' case is that we see MAP_FAILED.
This commit is contained in:
Ben Wiederhake 2021-03-10 20:02:48 +01:00 committed by Andreas Kling
parent bceb98e2df
commit 798dea7a49
Notes: sideshowbarker 2024-07-18 21:32:06 +09:00

View File

@ -238,7 +238,7 @@ int main(int argc, char** argv)
if (do_write_to_read_only_memory || do_all_crash_types) {
Crash("Write to read only memory", []() {
auto* ptr = (u8*)mmap(nullptr, 4096, PROT_READ | PROT_WRITE, MAP_ANON, 0, 0);
if (ptr != MAP_FAILED)
if (ptr == MAP_FAILED)
return Crash::Failure::UnexpectedError;
*ptr = 'x'; // This should work fine.