From c8e0da59d82fad8b04d63de21c222eebdf3c3c1b Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 17 Oct 2008 13:45:34 +0000 Subject: [PATCH] fix another WC2MB off-by-one error git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@56402 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/x11/clipbrd.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/x11/clipbrd.cpp b/src/x11/clipbrd.cpp index 69494fb10b..a5847a72b8 100644 --- a/src/x11/clipbrd.cpp +++ b/src/x11/clipbrd.cpp @@ -259,8 +259,14 @@ selection_handler( GtkWidget *WXUNUSED(widget), { const wchar_t *wstr = (const wchar_t *)d; size_t len = wxConvCurrent->WC2MB(NULL, wstr, 0); + if ( len == wxCONV_FAILED ) + { + free(d); + return; + } + char *str = malloc(len + 1); - wxConvCurrent->WC2MB(str, wstr, len); + wxConvCurrent->WC2MB(str, wstr, len + 1); str[len] = '\0'; free(d);