summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEero Tamminen <oak@helsinkinet.fi>2022-06-17 09:02:36 (GMT)
committerEero Tamminen <oak@helsinkinet.fi>2022-06-17 09:23:52 (GMT)
commit272b40ab7052e949d3b40bfd3b3b46318359412a (patch)
tree7ea925d7e1961064c6931f4a98ae948f65586750
parentdb4df0a1dc94452a1290ce21afe39d2de829e601 (diff)
downloadhatari-272b40ab7052e949d3b40bfd3b3b46318359412a.zip
hatari-272b40ab7052e949d3b40bfd3b3b46318359412a.tar.gz
Fix freeze with empty NatFeats NF_STDERR("") string
Fixes: b2a81850 (introduced in 2.3.0) Thanks to Matthias Arndt for reporting the issue, and Christian Zietz for debugging the cause for it!
-rw-r--r--doc/release-notes.txt2
-rw-r--r--src/debug/natfeats.c16
-rw-r--r--tests/natfeats/natfeats.c1
-rw-r--r--tests/natfeats/nf_ahcc.tosbin1352 -> 1360 bytes
4 files changed, 11 insertions, 8 deletions
diff --git a/doc/release-notes.txt b/doc/release-notes.txt
index d8db37f..7133303 100644
--- a/doc/release-notes.txt
+++ b/doc/release-notes.txt
@@ -103,6 +103,8 @@ Emulator improvements:
- Command line:
- Support "off" as alias for "none" when disabling DSP, FPU,
Joysticks and VME, for consistency with HW on/off options
+- NatFeats:
+ - Fix: freeze with NF_STDERR("")
- Debugger:
- Fix: profile header so that profile data post-processor knows how
to parse built-in WinAUE CPU core ("uae") disassembly output, not
diff --git a/src/debug/natfeats.c b/src/debug/natfeats.c
index 517ed1e..8d4e163 100644
--- a/src/debug/natfeats.c
+++ b/src/debug/natfeats.c
@@ -1,7 +1,7 @@
/*
* Hatari - natfeats.c
*
- * Copyright (C) 2012-2016, 2019 by Eero Tamminen
+ * Copyright (C) 2012-2016, 2019-2022 by Eero Tamminen
*
* This file is distributed under the GNU General Public License, version 2
* or at your option any later version. Read the file gpl.txt for details.
@@ -46,7 +46,7 @@ const char Natfeats_fileid[] = "Hatari natfeats.c";
* Check whether given string address is valid
* and whether strings is of "reasonable" length.
*
- * Returns string length or zero for error.
+ * Returns string length or negative value for error.
*/
static int mem_string_ok(Uint32 addr)
{
@@ -56,7 +56,7 @@ static int mem_string_ok(Uint32 addr)
if (!STMemory_CheckAreaType(addr, 1, ABFLAG_RAM | ABFLAG_ROM)) {
/* invalid starting address -> error */
M68000_BusError(addr, BUS_ERROR_READ, BUS_ERROR_SIZE_BYTE, BUS_ERROR_ACCESS_DATA, 0);
- return 0;
+ return -1;
}
buf = (const char *)STMemory_STAddrToPointer(addr);
if (STMemory_CheckAreaType(addr, NF_MAX_STRING, ABFLAG_RAM | ABFLAG_ROM)) {
@@ -66,19 +66,19 @@ static int mem_string_ok(Uint32 addr)
return i;
}
}
- return 0;
+ return -1;
}
for (i = 0; i < NF_MAX_STRING; i++) {
if (!STMemory_CheckAreaType(addr, 1, ABFLAG_RAM | ABFLAG_ROM)) {
/* ends in invalid area -> error */
M68000_BusError(addr, BUS_ERROR_READ, BUS_ERROR_SIZE_BYTE, BUS_ERROR_ACCESS_DATA, 0);
- return 0;
+ return -1;
}
if (!buf[i]) {
return i;
}
}
- return 0;
+ return -1;
}
/**
@@ -143,7 +143,7 @@ static bool nf_stderr(Uint32 stack, Uint32 subid, Uint32 *retval)
/* unrecognized subid, nothing printed */
return true;
}
- if (!mem_string_ok(ptr)) {
+ if (mem_string_ok(ptr) < 0) {
return false;
}
str = (const char *)STMemory_STAddrToPointer (ptr);
@@ -258,7 +258,7 @@ static bool nf_command(Uint32 stack, Uint32 subid, Uint32 *retval)
return true;
}
ptr = STMemory_ReadLong(stack);
- if (!mem_string_ok(ptr)) {
+ if (mem_string_ok(ptr) < 0) {
return false;
}
buffer = (const char *)STMemory_STAddrToPointer(ptr);
diff --git a/tests/natfeats/natfeats.c b/tests/natfeats/natfeats.c
index 0b455b8..7ea2f49 100644
--- a/tests/natfeats/natfeats.c
+++ b/tests/natfeats/natfeats.c
@@ -200,6 +200,7 @@ int main()
old_ff = nf_fastforward(1);
nf_print("Emulator name:\n");
nf_showname();
+ nf_print(""); /* check regression b2a81850 + its fix */
nf_print("Invoking debugger...\n");
nf_debugger();
nf_print("Restoring fastforward & shutting down...\n");
diff --git a/tests/natfeats/nf_ahcc.tos b/tests/natfeats/nf_ahcc.tos
index dfbc971..ff93ab0 100644
--- a/tests/natfeats/nf_ahcc.tos
+++ b/tests/natfeats/nf_ahcc.tos
Binary files differ