From e0a367202770227acf1d9ba88e3fc7e068547c37 Mon Sep 17 00:00:00 2001 From: Kevin Hock Date: Sun, 17 Jul 2005 03:15:50 +0000 Subject: [PATCH] Added null checks to wxTextObjectData::GetDataHere and GetDataSize [ patch 1237326 ] git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@34873 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/common/dobjcmn.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/common/dobjcmn.cpp b/src/common/dobjcmn.cpp index a37ffa50e6..ff161cddf3 100644 --- a/src/common/dobjcmn.cpp +++ b/src/common/dobjcmn.cpp @@ -287,7 +287,8 @@ size_t wxTextDataObject::GetDataSize(const wxDataFormat& format) const else // == wxDF_TEXT { wxCharBuffer buffer = wxConvLibc.cWX2MB( GetText().c_str() ); - return strlen( (const char*) buffer ) + 1; + // in some cases "buffer" is null (e.g. Mac OS X) + return buffer ? strlen( (const char*) buffer ) + 1 : 0; } } @@ -304,7 +305,9 @@ bool wxTextDataObject::GetDataHere(const wxDataFormat& format, void *buf) const else { wxCharBuffer buffer = wxConvLibc.cWX2MB( GetText().c_str() ); - strcpy( (char*) buf, (const char*) buffer ); + // in some cases "buffer" is null (e.g. Mac OS X) + if (buffer) + strcpy( (char*) buf, (const char*) buffer ); } return true; -- 2.45.2