seems like a false positive, unless there is an actual leak in other code and it's misattributing it here. Either way, I would send a bug report. Valgrind has no issues with this function.
(also, note that this is a pretty poor conversion, it kills every a non-ASCII value from your wide string. I would use std::codecvt_utf8 for something more reasonable)
I am very confused about using codecvt... Could Cubbi please show me how to accomplish the translation from wstring to string using the proposed codecvt_utf8?
(it may be convenient to create a converter once with std::wstring_convert<std::codecvt_utf8<wchar_t>> cvt; and use as-needed to call cvt.to_bytes(ws); or cvt.from_bytes(s);)