From 100d32a6a3cf2e638ce2fe4d8f8e4287cdd2e601 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 23 Jul 2009 15:01:32 +0000 Subject: [PATCH] Fix crash when copying Unicode URLs to the clipboard. Closes #11014. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@61506 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/changes.txt | 1 + src/msw/ole/dataobj.cpp | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index f847e95d4b..2f3b9a05c0 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -121,6 +121,7 @@ All (GUI): wxMSW: +- Fixed crash when copying Unicode URLs to the clipboard (Tim Kosse). - Fixed generation of wxEVT_CHAR_HOOK events. - Implement wxFileName::SetTimes() for directories (Steve Lamerton). - Correct wxTopLevelWindow::SetShape() for windows with menu bar (Peter Friis). diff --git a/src/msw/ole/dataobj.cpp b/src/msw/ole/dataobj.cpp index d23ae6fa6b..9a3cc03191 100644 --- a/src/msw/ole/dataobj.cpp +++ b/src/msw/ole/dataobj.cpp @@ -1264,8 +1264,12 @@ void wxURLDataObject::SetURL(const wxString& url) // CFSTR_SHELLURL is always supposed to be ANSI... wxWX2MBbuf urlA = (wxWX2MBbuf)url.mbc_str(); - size_t len = strlen(urlA); - SetData(wxDataFormat(CFSTR_SHELLURL), len+1, (const char*)urlA); + if ( url ) + { + size_t len = strlen(urlA); + SetData(wxDataFormat(CFSTR_SHELLURL), len+1, (const char*)urlA); + } + //else: we can't represent this URL in the current code page } // ----------------------------------------------------------------------------