summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam A. McKee <wamckee@msn.com>2023-01-06 14:59:11 -0500
committerWilliam A. McKee <wamckee@msn.com>2023-01-06 14:59:11 -0500
commit6a1cd8a40ac11d8a7dffcdc13c03225bb7e04b4f (patch)
tree111437e183ee7a764a8391cff9386e18158f4c51
parentc70f95e352b26e3bd486d6b2b23e3964f2b97a39 (diff)
Subtle problem with WideCharToMultiByte
-rw-r--r--RtAudio.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/RtAudio.cpp b/RtAudio.cpp
index 60008ec..af8b63c 100644
--- a/RtAudio.cpp
+++ b/RtAudio.cpp
@@ -78,7 +78,8 @@ const unsigned int RtApi::SAMPLE_RATES[] = {
{
int length = WideCharToMultiByte(CP_UTF8, 0, text, -1, NULL, 0, NULL, NULL);
std::string s( length-1, '\0' );
- WideCharToMultiByte(CP_UTF8, 0, text, -1, &s[0], length, NULL, NULL);
+ if (length > 1)
+ WideCharToMultiByte(CP_UTF8, 0, text, -1, &s[0], length-1, NULL, NULL);
return s;
}