summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDrChat <arkolbed@gmail.com>2018-02-14 16:21:16 -0600
committerDrChat <arkolbed@gmail.com>2018-02-14 16:21:16 -0600
commit7818cdab60c571f162b8bb752a1e817b1db108f2 (patch)
tree5b99b63078d1cebffb8b0b5be934114974b69af5
parent02b5a07bc9e2df713a42198ab09506669977454d (diff)
[CPU] Check for RawModule memory allocation success
-rw-r--r--src/xenia/cpu/raw_module.cc13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/xenia/cpu/raw_module.cc b/src/xenia/cpu/raw_module.cc
index 583a66922..ae51067c7 100644
--- a/src/xenia/cpu/raw_module.cc
+++ b/src/xenia/cpu/raw_module.cc
@@ -33,15 +33,18 @@ bool RawModule::LoadFile(uint32_t base_address, const std::wstring& path) {
// Allocate memory.
// Since we have no real heap just load it wherever.
base_address_ = base_address;
- memory_->LookupHeap(base_address_)
- ->AllocFixed(base_address_, file_length, 0,
- kMemoryAllocationReserve | kMemoryAllocationCommit,
- kMemoryProtectRead | kMemoryProtectWrite);
+ auto heap = memory_->LookupHeap(base_address_);
+ if (!heap ||
+ !heap->AllocFixed(base_address_, file_length, 0,
+ kMemoryAllocationReserve | kMemoryAllocationCommit,
+ kMemoryProtectRead | kMemoryProtectWrite)) {
+ return false;
+ }
+
uint8_t* p = memory_->TranslateVirtual(base_address_);
// Read into memory.
fread(p, file_length, 1, file);
-
fclose(file);
// Setup debug info.