From 22d03d497f0bf1aecb44a167ec06cc044a6d7c73 Mon Sep 17 00:00:00 2001 From: QRMOE Date: Mon, 12 Oct 2026 19:03:18 +0200 Subject: [PATCH] fix(libc): terminate truncated wcsxfrm results --- core/libs/prx/libc/src/Strings.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/core/libs/prx/libc/src/Strings.cpp b/core/libs/prx/libc/src/Strings.cpp index ebb046b03..096011360 100644 --- a/core/libs/prx/libc/src/Strings.cpp +++ b/core/libs/prx/libc/src/Strings.cpp @@ -499,7 +499,11 @@ int APS5_VABI wcscoll_nid_postfix(const char16_t* first, const char16_t* second) size_t APS5_VABI wcsxfrm_nid_postfix(char16_t* destination, const char16_t* source, size_t count) { const size_t length = Length(source); - if (length < count) std::memcpy(destination, source, (length + 1) * sizeof(char16_t)); + if (count != 0) { + const size_t copied = length < count ? length : count - 1; + std::memcpy(destination, source, copied * sizeof(char16_t)); + destination[copied] = 0; + } return length; }