diff --git a/app/src/main/cpp/skyline/kernel/svc.cpp b/app/src/main/cpp/skyline/kernel/svc.cpp index 3f5c14d1..ab8c16fd 100644 --- a/app/src/main/cpp/skyline/kernel/svc.cpp +++ b/app/src/main/cpp/skyline/kernel/svc.cpp @@ -176,7 +176,7 @@ namespace skyline::kernel::svc { if (!sourceObject) throw exception("svcUnmapMemory: Cannot find source memory object in handle table for address 0x{:X}", source); - state.process->memory.FreeMemory(sourceChunk.value().memory->guest); + state.process->memory.FreeMemory(std::span(source, size)); state.process->CloseHandle(sourceObject->handle); Logger::Debug("Unmapped range 0x{:X} - 0x{:X} to 0x{:X} - 0x{:X} (Size: 0x{:X} bytes)", source, source + size, destination, destination + size, size); @@ -1083,9 +1083,8 @@ namespace skyline::kernel::svc { if (memory->memoryState == memory::states::Heap) { if (memory->guest.data() >= pointer) { if (memory->guest.size() <= size) { - state.process->memory.FreeMemory(memory->guest); + memory->Resize(0); state.process->CloseHandle(memory->handle); - delete memory; } else { memory->Remap(span{pointer + size, static_cast((pointer + memory->guest.size() - memory->guest.data())) - size}); } @@ -1105,6 +1104,8 @@ namespace skyline::kernel::svc { } } + state.process->memory.FreeMemory(std::span(pointer, size)); + state.ctx->gpr.w0 = Result{}; }