Просмотр исходного кода

Userland: Add missing checks for MappedFile.is_valid()

Ben Wiederhake 5 лет назад
Родитель
Сommit
538a3a2579
2 измененных файлов с 6 добавлено и 0 удалено
  1. 4 0
      Userland/disasm.cpp
  2. 2 0
      Userland/unzip.cpp

+ 4 - 0
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);

+ 2 - 0
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());