Avoid using buffer of already deallocated string in wxHTMLDataObject.

Ensure that the temporary string inside which the pointer returned by
utf8_str() may point remains alive for long enough.

Closes #15279.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74429 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin 2013-07-07 00:38:41 +00:00
parent 38aae140ac
commit 8472511246

View File

@ -448,7 +448,10 @@ bool wxTextDataObject::SetData(size_t len, const void *buf)
size_t wxHTMLDataObject::GetDataSize() const
{
const wxScopedCharBuffer buffer(GetHTML().utf8_str());
// Ensure that the temporary string returned by GetHTML() is kept alive for
// as long as we need it here.
const wxString& htmlStr = GetHTML();
const wxScopedCharBuffer buffer(htmlStr.utf8_str());
size_t size = buffer.length();
@ -467,7 +470,8 @@ bool wxHTMLDataObject::GetDataHere(void *buf) const
return false;
// Windows and Mac always use UTF-8, and docs suggest GTK does as well.
const wxScopedCharBuffer html(GetHTML().utf8_str());
const wxString& htmlStr = GetHTML();
const wxScopedCharBuffer html(htmlStr.utf8_str());
if ( !html )
return false;