aboutsummaryrefslogtreecommitdiff
path: root/sftsr.c
diff options
context:
space:
mode:
authorJavier <dev.git@javispedro.com>2022-04-27 01:08:09 +0200
committerJavier <dev.git@javispedro.com>2022-04-27 01:08:09 +0200
commit13cc0921d8f9a0d488a27e2c86c1d9d013a964fe (patch)
tree7141ab5cc141044a1cbfe2055ac92b21aa41898c /sftsr.c
parent2aa8f27619b098baa7b8231255521c8d6c27c1db (diff)
downloadvbados-13cc0921d8f9a0d488a27e2c86c1d9d013a964fe.tar.gz
vbados-13cc0921d8f9a0d488a27e2c86c1d9d013a964fe.zip
fix leaking SFTs on close
Diffstat (limited to 'sftsr.c')
-rw-r--r--sftsr.c7
1 files changed, 7 insertions, 0 deletions
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;