Fix crash when using custom DnD formats under Wine

Using ::HeapSize() on a global pointer is wrong, and even though it
somehow still works under "genuine" MSW, it crashes under Wine.

Fix this by using ::GlobalSize() instead, which is the right function to
use with this kind of pointer.

Thanks to Damjan Jovanovic for the analysis of the problem in Wine
bugzilla (see https://bugs.winehq.org/show_bug.cgi?id=38924#c10).

Closes #18887.
This commit is contained in:
Vadim Zeitlin 2020-08-22 19:24:11 +02:00
parent 93c580ccaf
commit aadfaada7a

View File

@ -975,14 +975,10 @@ const void *wxDataObject::GetSizeFromBuffer(const void *buffer,
size_t *size,
const wxDataFormat& WXUNUSED(format))
{
// hack: the third parameter is declared non-const in Wine's headers so
// cast away the const
const size_t realsz = ::HeapSize(::GetProcessHeap(), 0,
const_cast<void*>(buffer));
if ( realsz == (size_t)-1 )
const size_t realsz = ::GlobalSize(::GlobalHandle(buffer));
if ( !realsz )
{
// note that HeapSize() does not set last error
wxLogApiError(wxT("HeapSize"), 0);
wxLogLastError(wxT("GlobalSize"));
return NULL;
}