]> git.saurik.com Git - wxWidgets.git/blobdiff - src/xml/xml.cpp
better check for conversion failure in OutputString(); use wxScopedCharBuffer::length...
[wxWidgets.git] / src / xml / xml.cpp
index 0f5e61d83cc943082540b8aeb504f6fd88a618f3..a37225c3dd7c7af074c02f35b69d5b1af23bca45 100644 (file)
@@ -783,12 +783,18 @@ bool OutputString(wxOutputStream& stream,
 
 #if wxUSE_UNICODE
     wxUnusedVar(convMem);
+    if ( !convFile )
+        convFile = &wxConvUTF8;
 
-    const wxWX2MBbuf buf(str.mb_str(*(convFile ? convFile : &wxConvUTF8)));
-    if ( !buf )
+    const wxScopedCharBuffer buf(str.mb_str(*convFile));
+    if ( !buf.length() )
+    {
+        // conversion failed, can't write this string in an XML file in this
+        // (presumably non-UTF-8) encoding
         return false;
+    }
 
-    stream.Write(buf, strlen(buf));
+    stream.Write(buf, buf.length());
 #else // !wxUSE_UNICODE
     if ( convFile && convMem )
     {