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.
This commit is contained in:
Rayyan Ansari
2023-11-05 20:21:16 +00:00
parent df571078cf
commit 0e4d082361

View File

@ -1109,7 +1109,7 @@ bool LoadROM(QStringList filepath, bool reset)
{ {
if (filepath.empty()) return false; if (filepath.empty()) return false;
u8* filedata; u8* filedata = nullptr;
u32 filelen; u32 filelen;
std::string basepath; std::string basepath;