- //do the actual conversion (if it fails we get an empty string)
- (*this) = wxWcstr(psz, nLen, conv);
+ //When converting mb->wc it never inflates to more characters than the length
+ wxWCharBuffer buffer(nLen + 1);
+
+ //Convert the string
+ size_t nActualLength = wxWcstr(buffer, psz, nLen, conv);
+
+ if ( !Alloc(nActualLength + 1) )
+ {
+ wxFAIL_MSG(wxT("Out of memory in wxString"));
+ }
+ else
+ {
+ //Copy the data
+ assign(buffer.data(), nActualLength);
+ }