diff --git a/src/gtk/textctrl.cpp b/src/gtk/textctrl.cpp index 5ec85604f1..8b1cf320b1 100644 --- a/src/gtk/textctrl.cpp +++ b/src/gtk/textctrl.cpp @@ -1002,6 +1002,12 @@ void wxTextCtrl::WriteText( const wxString &text ) #else wxCharBuffer buffer( wxConvUTF8.cWC2MB( wxConvLocal.cWX2WC( text ) ) ); #endif + if ( !buffer ) + { + // what else can we do? at least don't crash... + return; + } + gtk_editable_insert_text( GTK_EDITABLE(m_text), buffer, strlen(buffer), &len ); #else diff --git a/src/gtk1/textctrl.cpp b/src/gtk1/textctrl.cpp index 5ec85604f1..8b1cf320b1 100644 --- a/src/gtk1/textctrl.cpp +++ b/src/gtk1/textctrl.cpp @@ -1002,6 +1002,12 @@ void wxTextCtrl::WriteText( const wxString &text ) #else wxCharBuffer buffer( wxConvUTF8.cWC2MB( wxConvLocal.cWX2WC( text ) ) ); #endif + if ( !buffer ) + { + // what else can we do? at least don't crash... + return; + } + gtk_editable_insert_text( GTK_EDITABLE(m_text), buffer, strlen(buffer), &len ); #else