From bd3f83f763c9356063eab6690689f9ac9b52f0c0 Mon Sep 17 00:00:00 2001 From: Julian Smart Date: Sat, 24 Mar 2007 10:21:48 +0000 Subject: [PATCH] Test for encoding conversion success in wxFile::Write to avoid crash git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@45042 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/file.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/include/wx/file.h b/include/wx/file.h index 7f3f0e8184..5c193284d3 100644 --- a/include/wx/file.h +++ b/include/wx/file.h @@ -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(); -- 2.45.2