mirror of
https://github.com/FEX-Emu/FEX.git
synced 2026-10-14 19:00:43 +02:00
FEX: Consolidate JSON allocators and fix 3691
Fixes #3691 We weren't checking if the file was empty before using its `at` function member. This was causing an early crash if the config file existed but was empty. Consolidates the three locations that copy and pasted the json allocator tools and adds an empty check for all of them. Also adds two missing checks to the ThunksDB handler that could have resulted in the same crash if ThunksDB was an empty file.
This commit is contained in:
1 parent
89b05a2ea4
commit
30e3d795da
6 files changed
+67
-86
No files matched your search
@@ -0,0 +1,23 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
#include "Common/JSONPool.h"
|
||||
|
||||
namespace FEX::JSON {
|
||||
json_t* PoolInit(jsonPool_t* Pool);
|
||||
json_t* PoolAlloc(jsonPool_t* Pool);
|
||||
|
||||
JsonAllocator::JsonAllocator()
|
||||
: PoolObject {
|
||||
.init = FEX::JSON::PoolInit,
|
||||
.alloc = FEX::JSON::PoolAlloc,
|
||||
} {}
|
||||
|
||||
json_t* PoolInit(jsonPool_t* Pool) {
|
||||
JsonAllocator* alloc = reinterpret_cast<JsonAllocator*>(Pool);
|
||||
return &*alloc->json_objects.emplace(alloc->json_objects.end());
|
||||
}
|
||||
|
||||
json_t* PoolAlloc(jsonPool_t* Pool) {
|
||||
JsonAllocator* alloc = reinterpret_cast<JsonAllocator*>(Pool);
|
||||
return &*alloc->json_objects.emplace(alloc->json_objects.end());
|
||||
}
|
||||
} // namespace FEX::JSON
|
||||
Reference in new issue
Block a user