From 8936d789dadeb646ce0a824d2197edcb03b34442 Mon Sep 17 00:00:00 2001 From: cristian64 Date: Thu, 16 May 2024 21:49:25 +0100 Subject: [PATCH] Avoid prematurely freeing buffer during value editing on Linux. This was a regression in d58cd7687e272a576e49c, where the deletion of the `bufferCopy` buffer was moved to an earlier point. It was overlooked that the buffer is referenced by the `local` structure that used in the `process_vm_writev()` call. --- Source/DolphinProcess/Linux/LinuxDolphinProcess.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Source/DolphinProcess/Linux/LinuxDolphinProcess.cpp b/Source/DolphinProcess/Linux/LinuxDolphinProcess.cpp index a207b9d6..cf961d08 100644 --- a/Source/DolphinProcess/Linux/LinuxDolphinProcess.cpp +++ b/Source/DolphinProcess/Linux/LinuxDolphinProcess.cpp @@ -276,9 +276,10 @@ bool LinuxDolphinProcess::writeToRAM(const u32 offset, const char* buffer, const break; } } - delete[] bufferCopy; const ssize_t nwrote{process_vm_writev(m_PID, &local, 1, &remote, 1, 0)}; + delete[] bufferCopy; + if (nwrote == -1) { // A more specific error type should be available in `errno` (if ever interested).