From 2eb5e8189e52bb914ec62d22adb1db75331da990 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 2 Mar 2014 15:51:53 +0000 Subject: [PATCH] Fix off by 1 error in buffer size in wxOSX wxDropTarget code. The size of the buffer used for the data currently needs to include an extra byte for the trailing NUL. This is wrong, as it means that GetDataSize() and GetDataHere() behaviour is not consistent, but at least avoid overrunning the buffer for now. Also use wxCharBuffer instead of raw char array to make the code safer (both because it releases the memory automatically and because it also adds an extra byte for the trailing NUL automatically as well, making such bugs impossible). See #15914. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@76056 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/osx/dnd_osx.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/osx/dnd_osx.cpp b/src/osx/dnd_osx.cpp index ab6f153b53..4170c5a5cf 100644 --- a/src/osx/dnd_osx.cpp +++ b/src/osx/dnd_osx.cpp @@ -129,10 +129,9 @@ bool wxDropTarget::GetData() } else { - char *d = new char[size]; - data->GetDataHere( format, (void*)d ); - m_dataObject->SetData( format, size, d ); - delete [] d; + wxCharBuffer d(size); + data->GetDataHere( format, d.data() ); + m_dataObject->SetData( format, size, d.data() ); } } }