diff --git a/src/asm/actions.cpp b/src/asm/actions.cpp index 7ab356e5..7d011b16 100644 --- a/src/asm/actions.cpp +++ b/src/asm/actions.cpp @@ -555,7 +555,7 @@ std::string act_StringFormat( std::string str; size_t argIndex = 0; - for (size_t i = 0; spec[i] != '\0';) { + for (size_t i = 0; i < spec.length();) { if (int c = spec[i]; c != '%') { str += c; ++i; diff --git a/test/asm/strfmt.asm b/test/asm/strfmt.asm index 80a16f29..1ba29982 100644 --- a/test/asm/strfmt.asm +++ b/test/asm/strfmt.asm @@ -26,3 +26,7 @@ PRINTLN STRFMT("%d eol %", 1) PRINTLN STRFMT("invalid %w spec", 42) PRINTLN STRFMT("one=%d two=%d three=%d", 1) + +DEF NUL EQUS STRFMT("%s \0 %s", "goodbye", "world") +ASSERT #NUL === "goodbye \0 world" +PRINTLN #NUL diff --git a/test/asm/strfmt.out b/test/asm/strfmt.out index 2f3ec1cc..43f452d5 100644 Binary files a/test/asm/strfmt.out and b/test/asm/strfmt.out differ