mirror of
https://github.com/FEX-Emu/FEX.git
synced 2026-10-06 09:00:17 +02:00
ThreadManager: Fix error return values in FrontendAllocateSlots()
If ftruncate or the mmap ever fail for whatever reason, then we need to return the current size, rather than the new size.
This commit is contained in:
1 parent
f374b4775a
commit
331655182d
1 file changed
+7
-9
@@ -86,19 +86,17 @@ uint32_t ThreadManager::StatAlloc::FrontendAllocateSlots(uint32_t NewSize) {
|
||||
|
||||
if (ftruncate(fd, NewSize) == -1) {
|
||||
LogMan::Msg::EFmt("[StatAlloc] ftruncate more failed");
|
||||
|
||||
goto err;
|
||||
close(fd);
|
||||
return CurrentSize;
|
||||
}
|
||||
|
||||
{
|
||||
auto SharedBase = FEXCore::Allocator::mmap(Base, NewSize, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_FIXED, fd, 0);
|
||||
if (SharedBase == MAP_FAILED) {
|
||||
LogMan::Msg::EFmt("[StatAlloc] allocate more mmap shm failed");
|
||||
goto err;
|
||||
}
|
||||
auto SharedBase = FEXCore::Allocator::mmap(Base, NewSize, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_FIXED, fd, 0);
|
||||
if (SharedBase == MAP_FAILED) {
|
||||
LogMan::Msg::EFmt("[StatAlloc] allocate more mmap shm failed");
|
||||
close(fd);
|
||||
return CurrentSize;
|
||||
}
|
||||
|
||||
err:
|
||||
close(fd);
|
||||
return NewSize;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user