From 0e4d0823617240345cc8ac5f3703636d041c2df3 Mon Sep 17 00:00:00 2001 From: Rayyan Ansari Date: Sun, 5 Nov 2023 20:21:16 +0000 Subject: ROMManager: initialise filedata to nullptr If a user manages to open a file as a ROM that is greater than 1 GiB, it will cause a segmentation fault (a crash) in LoadROM due to a delete being called on an uninitialised pointer, which is undefined behaviour. Initialise filedata to nullptr to prevent this, as deleting a null pointer is defined as a no-op. --- src/frontend/qt_sdl/ROMManager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/frontend/qt_sdl/ROMManager.cpp b/src/frontend/qt_sdl/ROMManager.cpp index 6b4ddee..6b2b0b0 100644 --- a/src/frontend/qt_sdl/ROMManager.cpp +++ b/src/frontend/qt_sdl/ROMManager.cpp @@ -1109,7 +1109,7 @@ bool LoadROM(QStringList filepath, bool reset) { if (filepath.empty()) return false; - u8* filedata; + u8* filedata = nullptr; u32 filelen; std::string basepath; -- cgit v1.2.3