From 77da62969eb0b5efe4ce4a0c9ce67c45b9e32638 Mon Sep 17 00:00:00 2001 From: Kleis Auke Wolthuizen Date: Tue, 19 Jul 2022 21:33:13 +0200 Subject: [PATCH] [WasmFS] mmap: avoid setting *allocated too early (#17317) Setting `*allocated` here is too early, as read errors may occur (causing the pointer to be `free()`'d). --- system/lib/wasmfs/syscalls.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/system/lib/wasmfs/syscalls.cpp b/system/lib/wasmfs/syscalls.cpp index 6271c104a2f5b..7b6817f22a024 100644 --- a/system/lib/wasmfs/syscalls.cpp +++ b/system/lib/wasmfs/syscalls.cpp @@ -1529,7 +1529,6 @@ intptr_t _mmap_js( if (!ptr) { return -ENOMEM; } - *allocated = true; auto written = file->locked().read(ptr, length, offset); if (written < 0) {