diff --git a/src/asm/fstack.cpp b/src/asm/fstack.cpp index f928316e..01a026a9 100644 --- a/src/asm/fstack.cpp +++ b/src/asm/fstack.cpp @@ -356,11 +356,8 @@ void fstk_RunMacro(char const *macroName, MacroArgs &args) { std::vector const &srcIters = macro->src->iters(); for (uint32_t i = srcIters.size(); i--;) { - char buf[sizeof("::REPT~4294967295")]; // UINT32_MAX - - if (sprintf(buf, "::REPT~%" PRIu32, srcIters[i]) < 0) - fatalerror("Failed to write macro invocation info: %s\n", strerror(errno)); - fileInfoName.append(buf); + fileInfoName.append("::REPT~"); + fileInfoName.append(std::to_string(srcIters[i])); } } fileInfoName.append("::"); diff --git a/src/link/object.cpp b/src/link/object.cpp index 01411b0f..4568d065 100644 --- a/src/link/object.cpp +++ b/src/link/object.cpp @@ -462,10 +462,9 @@ static void readAssertion( uint32_t i, std::vector const &fileNodes ) { - char assertName[sizeof("Assertion #4294967295")]; // UINT32_MAX - - snprintf(assertName, sizeof(assertName), "Assertion #%" PRIu32, i); + std::string assertName("Assertion #"); + assertName += std::to_string(i); readPatch(file, assert.patch, fileName, assertName, 0, fileNodes); tryReadstring(assert.message, file, "%s: Cannot read assertion's message: %s", fileName); } diff --git a/test/gfx/rgbgfx_test.cpp b/test/gfx/rgbgfx_test.cpp index b3e58f56..58a40a5c 100644 --- a/test/gfx/rgbgfx_test.cpp +++ b/test/gfx/rgbgfx_test.cpp @@ -349,17 +349,13 @@ static char *execProg(char const *name, char * const *argv) { return buf; }; - char cmdLine[32768]; // Max command line size on Windows - char *ptr = cmdLine; + std::vector cmdLine; for (size_t i = 0; argv[i]; ++i) { - char const *src = argv[i]; - // I miss you, `stpcpy` - while (*src) { - *ptr++ = *src++; - } - *ptr++ = ' '; + if (i > 0) + cmdLine.push_back(' '); + cmdLine.insert(cmdLine.end(), argv[i], argv[i] + strlen(argv[i])); } - *ptr = '\0'; + cmdLine.push_back('\0'); STARTUPINFOA startupInfo; GetStartupInfoA(&startupInfo); @@ -386,7 +382,16 @@ static char *execProg(char const *name, char * const *argv) { PROCESS_INFORMATION child; if (CreateProcessA( - nullptr, cmdLine, nullptr, nullptr, true, 0, nullptr, nullptr, &childStartupInfo, &child + nullptr, + cmdLine.data(), + nullptr, + nullptr, + true, + 0, + nullptr, + nullptr, + &childStartupInfo, + &child ) == 0) { return winStrerror(GetLastError());