From 13cc0921d8f9a0d488a27e2c86c1d9d013a964fe Mon Sep 17 00:00:00 2001 From: Javier Date: Wed, 27 Apr 2022 01:08:09 +0200 Subject: fix leaking SFTs on close --- sftsr.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'sftsr.c') diff --git a/sftsr.c b/sftsr.c index fa2097e..62e1734 100644 --- a/sftsr.c +++ b/sftsr.c @@ -43,6 +43,8 @@ static uint8_t map_shfl_attr_to_dosattr(const SHFLFSOBJATTR *a) { // DOS attributes are in the higher word of fMode (see RTFS_DOS_*) uint8_t attr = (a->fMode >> 16) & 0x3F; + // Albeit also map the UNIX S_IFDIR attrib to DOS SUBDIR one, + // since at least on Linux hosts the DOS one may not be set if (a->fMode & 0x4000U) attr |= _A_SUBDIR; return attr; } @@ -487,6 +489,11 @@ static void handle_close(union INTPACK __far *r) } dos_sft_decref(sft); + if (sft->num_handles == 0xFFFF) { + // SFT is no longer referenced, clear it up + set_sft_openfile_index(sft, 0); + sft->num_handles = 0; + } data.files[openfile].root = SHFL_ROOT_NIL; data.files[openfile].handle = SHFL_HANDLE_NIL; -- cgit v1.2.3