]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/fs_mem.cpp
fixing overrelease and out-of-bounds write, fixes #13725
[wxWidgets.git] / src / common / fs_mem.cpp
index 28b43e826f0aebeb4c6a8dab3ba002501aa25a65..5f96257100180f37ed3a5b1f55a4ed56d245f010 100644 (file)
@@ -186,15 +186,9 @@ void wxMemoryFSHandlerBase::AddFileWithMimeType(const wxString& filename,
                                                 const wxString& textdata,
                                                 const wxString& mimetype)
 {
-#if wxUSE_UNICODE
-    const wxScopedCharBuffer data(textdata.To8BitData());
-#else
-    const wxString& data = textdata;
-#endif
+    const wxCharBuffer buf(textdata.To8BitData());
 
-    AddFileWithMimeType(filename,
-                        static_cast<const char *>(data), data.length(),
-                        mimetype);
+    AddFileWithMimeType(filename, buf.data(), buf.length(), mimetype);
 }
 
 
@@ -255,7 +249,7 @@ wxMemoryFSHandler::AddFile(const wxString& filename,
         return;
 
     wxMemoryOutputStream mems;
-    if ( image.Ok() && image.SaveFile(mems, type) )
+    if ( image.IsOk() && image.SaveFile(mems, type) )
     {
         m_Hash[filename] = new wxMemoryFSFile
                                (