mirror of
https://git.suyu.dev/suyu/suyu
synced 2024-11-01 04:47:53 +00:00
NCCH: Updated ExeFS memory allocation to be safer.
This commit is contained in:
parent
542700ccb7
commit
b70c4fb48e
2 changed files with 7 additions and 1 deletions
|
@ -32,6 +32,7 @@ enum class ResultStatus {
|
|||
ErrorNotLoaded,
|
||||
ErrorNotUsed,
|
||||
ErrorAlreadyLoaded,
|
||||
ErrorMemoryAllocationFailed,
|
||||
};
|
||||
|
||||
/// Interface for loading an application
|
||||
|
|
|
@ -157,7 +157,12 @@ ResultStatus AppLoader_NCCH::LoadSectionExeFS(const char* name, std::vector<u8>&
|
|||
// Section is compressed...
|
||||
if (i == 0 && is_compressed) {
|
||||
// Read compressed .code section...
|
||||
std::unique_ptr<u8[]> temp_buffer(new u8[exefs_header.section[i].size]);
|
||||
std::unique_ptr<u8[]> temp_buffer;
|
||||
try {
|
||||
temp_buffer.reset(new u8[exefs_header.section[i].size]);
|
||||
} catch (std::bad_alloc&) {
|
||||
return ResultStatus::ErrorMemoryAllocationFailed;
|
||||
}
|
||||
file.ReadBytes(&temp_buffer[0], exefs_header.section[i].size);
|
||||
|
||||
// Decompress .code section...
|
||||
|
|
Loading…
Reference in a new issue