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:
parent
93c580ccaf
commit
aadfaada7a
@ -975,14 +975,10 @@ const void *wxDataObject::GetSizeFromBuffer(const void *buffer,
|
|||||||
size_t *size,
|
size_t *size,
|
||||||
const wxDataFormat& WXUNUSED(format))
|
const wxDataFormat& WXUNUSED(format))
|
||||||
{
|
{
|
||||||
// hack: the third parameter is declared non-const in Wine's headers so
|
const size_t realsz = ::GlobalSize(::GlobalHandle(buffer));
|
||||||
// cast away the const
|
if ( !realsz )
|
||||||
const size_t realsz = ::HeapSize(::GetProcessHeap(), 0,
|
|
||||||
const_cast<void*>(buffer));
|
|
||||||
if ( realsz == (size_t)-1 )
|
|
||||||
{
|
{
|
||||||
// note that HeapSize() does not set last error
|
wxLogLastError(wxT("GlobalSize"));
|
||||||
wxLogApiError(wxT("HeapSize"), 0);
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user