Patch #2891 2009-12-30 21:19

techy

Check return value of wxEncodingConverter::Init() (debug18)
Download
2891-Check_return_v.patch (833 bytes)
Category
Application::Bugfix
Status
Accepted
Close date
2009-12-31 16:55
Assigned to
mortenmacfly
Index: src/sdk/encodingdetector.cpp
===================================================================
--- src/sdk/encodingdetector.cpp    (revision 5987)
+++ src/sdk/encodingdetector.cpp    (working copy)
@@ -182,9 +182,8 @@
         // wxFONTENCODING_ISO8859_1..15, wxFONTENCODING_CP1250..1257 and wxFONTENCODING_KOI8
         // but it's much, much faster than wxCSConv (at least on linux)
         wxEncodingConverter conv;
-        conv.Init(m_Encoding, wxFONTENCODING_UNICODE);
         wchar_t* tmp = new wchar_t[size + 4 - m_BOMSizeInBytes];
-        if(conv.Convert((char*)buffer, tmp))
+        if(conv.Init(m_Encoding, wxFONTENCODING_UNICODE) && conv.Convert((char*)buffer, tmp))
         {
             wideBuff = tmp;
             outlen = size + 4 - m_BOMSizeInBytes; // should be correct, because Convert has returned true
techy 2009-12-30 21:20

If Init() fails, don't call Convert()...