]> git.saurik.com Git - wxWidgets.git/commitdiff
Test for encoding conversion success in wxFile::Write to avoid crash
authorJulian Smart <julian@anthemion.co.uk>
Sat, 24 Mar 2007 10:21:48 +0000 (10:21 +0000)
committerJulian Smart <julian@anthemion.co.uk>
Sat, 24 Mar 2007 10:21:48 +0000 (10:21 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@45042 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/file.h

index 7f3f0e8184add500a6d9a4ecfae377a305c37676..5c193284d398b79f60c3c6377b917521ca024aed 100644 (file)
@@ -100,8 +100,13 @@ public:
   bool Write(const wxString& s, const wxMBConv& conv = wxConvUTF8)
   {
       const wxWX2MBbuf buf = s.mb_str(conv);
-      size_t size = strlen(buf);
-      return Write((const char *) buf, size) == size;
+      if (buf)
+      {
+             size_t size = strlen(buf);
+             return Write((const char *) buf, size) == size;
+         }
+      else
+          return false;
   }
     // flush data not yet written
   bool Flush();