From: Francesco Montorsi <f18m_cpp217828@yahoo.it>
Date: Fri, 6 Mar 2009 22:45:00 +0000 (+0000)
Subject: fix wxTextDataObject::GetDataHere and SetData functions (under wxMSW) so that they... 
X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/f453d7eadaf93af1d84981a1d1ead8e04be9522f

fix wxTextDataObject::GetDataHere and SetData functions (under wxMSW) so that they work with strings with embedded NULLs and can cope with non-NULL terminated arrays.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@59391 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
---

diff --git a/src/common/dobjcmn.cpp b/src/common/dobjcmn.cpp
index 20d6b2999c..bb3bc30971 100644
--- a/src/common/dobjcmn.cpp
+++ b/src/common/dobjcmn.cpp
@@ -422,14 +422,16 @@ size_t wxTextDataObject::GetDataSize() const
 
 bool wxTextDataObject::GetDataHere(void *buf) const
 {
-    wxStrcpy( (wxChar*)buf, GetText().c_str() );
+    // NOTE: use wxTmemcpy() instead of wxStrncpy() to allow
+    //       retrieval of strings with embedded NULLs
+    wxTmemcpy( (wxChar*)buf, GetText().c_str(), GetTextLength() );
 
     return true;
 }
 
-bool wxTextDataObject::SetData(size_t WXUNUSED(len), const void *buf)
+bool wxTextDataObject::SetData(size_t len, const void *buf)
 {
-    SetText( wxString((const wxChar*)buf) );
+    SetText( wxString((const wxChar*)buf, len/sizeof(wxChar)) );
 
     return true;
 }