Compare commits

...

2 commits

Author SHA1 Message Date
William Wilgus
951cbdbec6 [bugfix] FS#13812 - ZXBox always returns a leak file handles error
tapefiles return a leak handle error if it is quit before end of tape is
reached, ensure it always gets closed on exit

Change-Id: I0f6224c7164fd87c209166be9e10d62d6a644a50
2026-03-08 12:07:53 -04:00
William Wilgus
4503d63ec8 [bugfix] zxbox unsupported files crash OOB access to extension list
invalid files return -1 but thats not checked before accessing
invalid array position

Change-Id: Ic07cca250e2584e2e95fa7c41085b254f94ad591
2026-03-08 11:26:12 -04:00
2 changed files with 10 additions and 3 deletions

View file

@ -106,9 +106,13 @@ static int find_extension(const char *ext)
void spcf_read_command_line(const void* parameter) void spcf_read_command_line(const void* parameter)
{ {
int ix; int ix;
const char *ext = rb->strrchr(parameter, '.');
ix = find_extension( parameter - 3 + rb->strlen (parameter) ); ix = (ext ? find_extension(ext+1) : -1);
if (ix < 0)
{
rb->splash(HZ*2, "Invalid extension");
return;
}
file_type = extensions[ix].type; file_type = extensions[ix].type;
file_subtype = extensions[ix].subtype; file_subtype = extensions[ix].subtype;
rb->strlcpy(filenamebuf, parameter, MAXFILENAME - 10 + 1); rb->strlcpy(filenamebuf, parameter, MAXFILENAME - 10 + 1);

View file

@ -47,6 +47,8 @@
#include "zxbox_keyb.h" #include "zxbox_keyb.h"
#include "tapefile.h"
int endofsingle IBSS_ATTR; int endofsingle IBSS_ATTR;
int sp_nosync IBSS_ATTR = 0; int sp_nosync IBSS_ATTR = 0;
@ -519,4 +521,5 @@ void start_spectemu(const void *parameter)
init_spect_key(); init_spect_key();
run_singlemode(); run_singlemode();
close_tapefile(); /* Bugfix leak file handles */
} }