diff options
author | Nat Goodspeed <nat@lindenlab.com> | 2021-11-02 17:27:59 -0400 |
---|---|---|
committer | Nat Goodspeed <nat@lindenlab.com> | 2021-11-02 17:27:59 -0400 |
commit | a33718ee4ca4edbbc4c4034b29ec4c8d102f3a7e (patch) | |
tree | 6431109dd8099d7dd5ee1865760630cf580b1965 /indra/llcommon/llstring.cpp | |
parent | 95958bc8b2a5340bef93996f2ff0c04956bfb743 (diff) |
SL-16207: Fix bug in ll_convert_string_to_utf8_string().
That function wants to pass a code_page to ll_convert_string_to_wide(), but
the code_page parameter was being mistaken for the length parameter, leading
to access violations.
Diffstat (limited to 'indra/llcommon/llstring.cpp')
-rw-r--r-- | indra/llcommon/llstring.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/indra/llcommon/llstring.cpp b/indra/llcommon/llstring.cpp index 5f426e5dca..03f706f5a5 100644 --- a/indra/llcommon/llstring.cpp +++ b/indra/llcommon/llstring.cpp @@ -712,10 +712,11 @@ std::wstring ll_convert_wstring_to_wide(const llwchar* in, size_t len) std::string ll_convert_string_to_utf8_string(const std::string& in) { - auto w_mesg = ll_convert_string_to_wide(in, CP_ACP); - std::string out_utf8(ll_convert_wide_to_string(w_mesg.c_str(), CP_UTF8)); - - return out_utf8; + // If you pass code_page, you must also pass length, otherwise the code + // page parameter will be mistaken for length. + auto w_mesg = ll_convert_string_to_wide(in, in.length(), CP_ACP); + // CP_UTF8 is default -- see ll_wstring_default_code_page() above. + return ll_convert_wide_to_string(w_mesg); } namespace |