From 538a3a2579fbd93deeb23a41ea4de641d384933c Mon Sep 17 00:00:00 2001 From: Ben Wiederhake Date: Fri, 31 Jul 2020 11:21:33 +0200 Subject: [PATCH] Userland: Add missing checks for MappedFile.is_valid() --- Userland/disasm.cpp | 4 ++++ Userland/unzip.cpp | 2 ++ 2 files changed, 6 insertions(+) diff --git a/Userland/disasm.cpp b/Userland/disasm.cpp index 3e03a5572e..3cd61907da 100644 --- a/Userland/disasm.cpp +++ b/Userland/disasm.cpp @@ -37,6 +37,10 @@ int main(int argc, char** argv) } MappedFile file(argv[1]); + if (!file.is_valid()) { + // Already printed some error message. + return 1; + } X86::SimpleInstructionStream stream((const u8*)file.data(), file.size()); X86::Disassembler disassembler(stream); diff --git a/Userland/unzip.cpp b/Userland/unzip.cpp index 93245c2ae7..7fc6bfd921 100644 --- a/Userland/unzip.cpp +++ b/Userland/unzip.cpp @@ -183,6 +183,8 @@ int main(int argc, char** argv) } MappedFile mapped_file { zip_file_path }; + if (!mapped_file.is_valid()) + return 1; printf("Archive: %s\n", zip_file_path.characters());