From baaf1f548edaec11e90dc2aa730b612ae3c9f373 Mon Sep 17 00:00:00 2001 From: Dirk Stolle Date: Sun, 12 Jul 2026 03:23:24 +0200 Subject: [PATCH] guard WideCharToMultiByte() against empty strings This should fix . --- src/detail/utf8.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/detail/utf8.cpp b/src/detail/utf8.cpp index f6274cfc8..a657b120c 100644 --- a/src/detail/utf8.cpp +++ b/src/detail/utf8.cpp @@ -37,6 +37,8 @@ inline void handle_error(error_code & ec) std::size_t size_as_utf8(const wchar_t * in, std::size_t size, error_code & ec) { + if (size == 0u) + return 0u; auto res = WideCharToMultiByte( CP_UTF8, // CodePage, 0, // dwFlags, @@ -72,6 +74,8 @@ std::size_t size_as_wide(const char * in, std::size_t size, error_code & ec) std::size_t convert_to_utf8(const wchar_t *in, std::size_t size, char * out, std::size_t max_size, error_code & ec) { + if (size == 0u) + return 0u; auto res = ::WideCharToMultiByte( CP_UTF8, // CodePage 0, // dwFlags