]> git.saurik.com Git - wxWidgets.git/blobdiff - src/osx/carbon/textctrl.cpp
add missing Detach() after r56863 changes (thanks troelsk)
[wxWidgets.git] / src / osx / carbon / textctrl.cpp
index f385f45e0666e815f0648b61c98bce2e8792a9f7..fc308b671229bb40f6fa7f26f9abf725852c130f 100644 (file)
@@ -950,7 +950,7 @@ void wxMacMLTEControl::SetBackgroundColour(const wxColour& col )
 
 static inline int wxConvertToTXN(int x)
 {
-    return wx_static_cast(int, x / 254.0 * 72 + 0.5);
+    return static_cast<int>(x / 254.0 * 72 + 0.5);
 }
 
 void wxMacMLTEControl::TXNSetAttribute( const wxTextAttr& style , long from , long to )
@@ -1371,8 +1371,10 @@ void wxMacMLTEControl::SetTXNData( const wxString& st, TXNOffset start, TXNOffse
 #else
     wxMBConvUTF16 converter ;
     ByteCount byteBufferLen = converter.WC2MB( NULL, st.wc_str(), 0 ) ;
-    UniChar *unibuf = (UniChar*)malloc( byteBufferLen ) ;
-    converter.WC2MB( (char*)unibuf, st.wc_str(), byteBufferLen ) ;
+    wxASSERT_MSG( byteBufferLen != wxCONV_FAILED,
+                  _T("Conversion to UTF-16 unexpectedly failed") );
+    UniChar *unibuf = (UniChar*)malloc( byteBufferLen + 2 ) ; // 2 for NUL in UTF-16
+    converter.WC2MB( (char*)unibuf, st.wc_str(), byteBufferLen + 2 ) ;
     TXNSetData( m_txn, kTXNUnicodeTextData, (void*)unibuf, byteBufferLen, start, end ) ;
     free( unibuf ) ;
 #endif