From 21dc1a1d4f2453443f658f408c759379ebf51b40 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 25 Dec 2014 01:32:10 +0000 Subject: [PATCH] Blind fix for wxTextDataObject trailing NUL under OS X. Use the length provided to SetData() instead of assuming it is NUL-terminated. Closes #9522. (this is a backport of 20c130a57835261e7e7327fe85e95c76c5fe31af from master) --- docs/changes.txt | 1 + src/common/dobjcmn.cpp | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index d266d58964..c6da3cf267 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -633,6 +633,7 @@ wxOSX: - Compilation fix for wxWebView under 10.10. - Fix conversion of wxBitmap to wxImage in 64 bit builds. +- Fix length of text in wxTextDataObject. - Fix using wxHTTP and wxFTP from worker thread. - Fix wxFileDialog::GetFilterIndex() for file open dialogs (phsilva). - Fix custom paper support (tijsv). diff --git a/src/common/dobjcmn.cpp b/src/common/dobjcmn.cpp index 5e4d43dcc0..10ba0a267a 100644 --- a/src/common/dobjcmn.cpp +++ b/src/common/dobjcmn.cpp @@ -284,12 +284,12 @@ bool wxTextDataObject::GetDataHere(const wxDataFormat& format, void *buf) const } bool wxTextDataObject::SetData(const wxDataFormat& format, - size_t WXUNUSED(len), const void *buf) + size_t len, const void *buf) { if ( buf == NULL ) return false; - wxWCharBuffer buffer = GetConv(format).cMB2WX( (const char*)buf ); + wxWCharBuffer buffer = GetConv(format).cMB2WC((const char*)buf, len, NULL); SetText( buffer );