[CPU/Posix] Fixed crash caused by calling mmap on empty file

This commit is contained in:
Gliniak
2026-04-19 20:21:24 +02:00
parent bc7bc76d68
commit 049a55f036

View File

@@ -1372,20 +1372,20 @@ void XexInfoCache::Init(XexModule* xexmod) {
auto try_open = [this, &infocache_path, num_codebytes]() {
bool did_exist = true;
const size_t file_size = sizeof(InfoCacheFlagsHeader) +
(sizeof(InfoCacheFlags) * (num_codebytes / 4));
if (!std::filesystem::exists(infocache_path)) {
xe::filesystem::CreateEmptyFile(infocache_path);
std::filesystem::resize_file(infocache_path, file_size);
did_exist = false;
}
// todo: prepopulate with stuff from pdata, dll exports
this->executable_addr_flags_ = std::move(xe::MappedMemory::Open(
this->executable_addr_flags_ = MappedMemory::Open(
infocache_path, xe::MappedMemory::Mode::kReadWrite, 0,
sizeof(InfoCacheFlagsHeader) +
(sizeof(InfoCacheFlags) *
(num_codebytes /
4)))); // one infocacheflags entry for each PPC instr-sized addr
file_size); // one infocacheflags entry for each PPC instr-sized addr
return did_exist;
};