From c8575743d2413caa1eae3e465e641213e5e72d87 Mon Sep 17 00:00:00 2001 From: LionelDrew Date: Wed, 7 Jan 2026 08:57:06 +0800 Subject: [PATCH] Fixed a crash when messages were too long. --- src/utility.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/utility.cpp b/src/utility.cpp index 2b4492a1..0179acc5 100644 --- a/src/utility.cpp +++ b/src/utility.cpp @@ -883,11 +883,16 @@ VOID Print (LPWSTR messagew) const size_t MAXMESSAGELENGTH = 5119; size_t count = 0; CHAR messagea [MAXMESSAGELENGTH + 1]; - if (wcstombs_s(&count, messagea, MAXMESSAGELENGTH + 1, messagew, _TRUNCATE) != 0) { + if (wcstombs_s(&count, messagea, MAXMESSAGELENGTH + 1, messagew, MAXMESSAGELENGTH) != 0) { // Failed to convert the Unicode message to ASCII. assert(FALSE); return; } + if (count >= MAXMESSAGELENGTH) + { + Report(L"!!! Print Warning, the message was too long and has been truncated.\n"); + } + messagea[MAXMESSAGELENGTH] = '\0'; if (s_reportFile != NULL) {