From ab4a00025fe61d6c7f27e084cb6fc70e140ea297 Mon Sep 17 00:00:00 2001 From: Simon Dick Date: Fri, 23 Oct 2026 16:11:14 +0100 Subject: [PATCH] dos.library: new_lock frees the FileLock block if fs_port_addr fails alloc_lock_struct() can succeed and then fs_port_addr() fail (e.g. a near-exhausted guest heap on the first lock ever created), propagating the error without freeing the just-allocated block or registering it in self.locks -- orphaning it from the heap's free list for the rest of the run. Co-Authored-By: Claude Sonnet 5 --- crates/volamos-core/src/doslock.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/crates/volamos-core/src/doslock.rs b/crates/volamos-core/src/doslock.rs index d8fa5c6..3540bd7 100644 --- a/crates/volamos-core/src/doslock.rs +++ b/crates/volamos-core/src/doslock.rs @@ -265,7 +265,13 @@ impl DosState { // real, PutMsg-interceptable port rather than `0` changes // nothing observable for a guest that (like every other caller // so far) never sends it packets at all. - let fl_task = self.fs_port_addr(heap, mem)?; + let fl_task = match self.fs_port_addr(heap, mem) { + Ok(fl_task) => fl_task, + Err(e) => { + let _ = heap.free(addr); + return Err(e); + } + }; mem.write_u32(addr.wrapping_add(FL_TASK_OFFSET), fl_task); self.locks.insert( addr,