diff options
| author | 2014-07-04 20:32:06 -0400 | |
|---|---|---|
| committer | 2014-07-04 20:37:51 -0400 | |
| commit | b70c4fb48ec32057e56d9c0373794670bddd4f34 (patch) | |
| tree | 6bb6ab148504beaacdfa02ed1dd069e3a5f61427 | |
| parent | Archive: Added Init/Shutdown methods to reset kernel archive state. (diff) | |
| download | yuzu-b70c4fb48ec32057e56d9c0373794670bddd4f34.tar.gz yuzu-b70c4fb48ec32057e56d9c0373794670bddd4f34.tar.xz yuzu-b70c4fb48ec32057e56d9c0373794670bddd4f34.zip | |
NCCH: Updated ExeFS memory allocation to be safer.
| -rw-r--r-- | src/core/loader/loader.h | 1 | ||||
| -rw-r--r-- | src/core/loader/ncch.cpp | 7 |
2 files changed, 7 insertions, 1 deletions
diff --git a/src/core/loader/loader.h b/src/core/loader/loader.h index c27b5b4b6..4ba10de52 100644 --- a/src/core/loader/loader.h +++ b/src/core/loader/loader.h | |||
| @@ -32,6 +32,7 @@ enum class ResultStatus { | |||
| 32 | ErrorNotLoaded, | 32 | ErrorNotLoaded, |
| 33 | ErrorNotUsed, | 33 | ErrorNotUsed, |
| 34 | ErrorAlreadyLoaded, | 34 | ErrorAlreadyLoaded, |
| 35 | ErrorMemoryAllocationFailed, | ||
| 35 | }; | 36 | }; |
| 36 | 37 | ||
| 37 | /// Interface for loading an application | 38 | /// Interface for loading an application |
diff --git a/src/core/loader/ncch.cpp b/src/core/loader/ncch.cpp index a82338904..ba27eb75a 100644 --- a/src/core/loader/ncch.cpp +++ b/src/core/loader/ncch.cpp | |||
| @@ -157,7 +157,12 @@ ResultStatus AppLoader_NCCH::LoadSectionExeFS(const char* name, std::vector<u8>& | |||
| 157 | // Section is compressed... | 157 | // Section is compressed... |
| 158 | if (i == 0 && is_compressed) { | 158 | if (i == 0 && is_compressed) { |
| 159 | // Read compressed .code section... | 159 | // Read compressed .code section... |
| 160 | std::unique_ptr<u8[]> temp_buffer(new u8[exefs_header.section[i].size]); | 160 | std::unique_ptr<u8[]> temp_buffer; |
| 161 | try { | ||
| 162 | temp_buffer.reset(new u8[exefs_header.section[i].size]); | ||
| 163 | } catch (std::bad_alloc&) { | ||
| 164 | return ResultStatus::ErrorMemoryAllocationFailed; | ||
| 165 | } | ||
| 161 | file.ReadBytes(&temp_buffer[0], exefs_header.section[i].size); | 166 | file.ReadBytes(&temp_buffer[0], exefs_header.section[i].size); |
| 162 | 167 | ||
| 163 | // Decompress .code section... | 168 | // Decompress .code section... |