From 798dea7a4964b08b9aeec2e68183819262b40daf Mon Sep 17 00:00:00 2001 From: Ben Wiederhake Date: Wed, 10 Mar 2021 20:02:48 +0100 Subject: [PATCH] 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. --- Userland/Utilities/crash.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Userland/Utilities/crash.cpp b/Userland/Utilities/crash.cpp index 817dbc300e..cb9cad0cbf 100644 --- a/Userland/Utilities/crash.cpp +++ b/Userland/Utilities/crash.cpp @@ -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.