Fixed DDE in Unicode: bug [ 1206299 ] wxDDE 'segfaults'
Steven Van Ingelgem git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@34235 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -44,6 +44,7 @@
|
|||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <ddeml.h>
|
#include <ddeml.h>
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// macros and constants
|
// macros and constants
|
||||||
@@ -594,8 +595,9 @@ wxChar *wxDDEConnection::Request(const wxString& item, int *size, wxIPCFormat fo
|
|||||||
}
|
}
|
||||||
|
|
||||||
DWORD len = DdeGetData(returned_data, NULL, 0, 0);
|
DWORD len = DdeGetData(returned_data, NULL, 0, 0);
|
||||||
|
len = ceil( static_cast<double>(len)/sizeof(wxChar) );
|
||||||
|
|
||||||
wxChar *data = GetBufferAtLeast( len/sizeof(wxChar) );
|
wxChar *data = GetBufferAtLeast( len );
|
||||||
wxASSERT_MSG(data != NULL,
|
wxASSERT_MSG(data != NULL,
|
||||||
_T("Buffer too small in wxDDEConnection::Request") );
|
_T("Buffer too small in wxDDEConnection::Request") );
|
||||||
(void) DdeGetData(returned_data, (LPBYTE)data, len, 0);
|
(void) DdeGetData(returned_data, (LPBYTE)data, len, 0);
|
||||||
@@ -603,7 +605,7 @@ wxChar *wxDDEConnection::Request(const wxString& item, int *size, wxIPCFormat fo
|
|||||||
(void) DdeFreeDataHandle(returned_data);
|
(void) DdeFreeDataHandle(returned_data);
|
||||||
|
|
||||||
if (size)
|
if (size)
|
||||||
*size = (int)len/sizeof(wxChar);
|
*size = len;
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
@@ -775,8 +777,9 @@ _DDECallback(WORD wType,
|
|||||||
if (connection)
|
if (connection)
|
||||||
{
|
{
|
||||||
DWORD len = DdeGetData(hData, NULL, 0, 0);
|
DWORD len = DdeGetData(hData, NULL, 0, 0);
|
||||||
|
len = ceil( static_cast<double>(len)/sizeof(wxChar) );
|
||||||
|
|
||||||
wxChar *data = connection->GetBufferAtLeast( len/sizeof(wxChar) );
|
wxChar *data = connection->GetBufferAtLeast( len );
|
||||||
wxASSERT_MSG(data != NULL,
|
wxASSERT_MSG(data != NULL,
|
||||||
_T("Buffer too small in _DDECallback (XTYP_EXECUTE)") );
|
_T("Buffer too small in _DDECallback (XTYP_EXECUTE)") );
|
||||||
|
|
||||||
@@ -786,7 +789,7 @@ _DDECallback(WORD wType,
|
|||||||
|
|
||||||
if ( connection->OnExecute(connection->m_topicName,
|
if ( connection->OnExecute(connection->m_topicName,
|
||||||
data,
|
data,
|
||||||
(int)len/sizeof(wxChar),
|
(int)len,
|
||||||
(wxIPCFormat) wFmt) )
|
(wxIPCFormat) wFmt) )
|
||||||
{
|
{
|
||||||
return (DDERETURN)(DWORD)DDE_FACK;
|
return (DDERETURN)(DWORD)DDE_FACK;
|
||||||
@@ -836,8 +839,9 @@ _DDECallback(WORD wType,
|
|||||||
wxString item_name = DDEStringFromAtom(hsz2);
|
wxString item_name = DDEStringFromAtom(hsz2);
|
||||||
|
|
||||||
DWORD len = DdeGetData(hData, NULL, 0, 0);
|
DWORD len = DdeGetData(hData, NULL, 0, 0);
|
||||||
|
len = ceil( static_cast<double>(len) / sizeof(wxChar) );
|
||||||
|
|
||||||
wxChar *data = connection->GetBufferAtLeast( len/sizeof(wxChar) );
|
wxChar *data = connection->GetBufferAtLeast( len );
|
||||||
wxASSERT_MSG(data != NULL,
|
wxASSERT_MSG(data != NULL,
|
||||||
_T("Buffer too small in _DDECallback (XTYP_EXECUTE)") );
|
_T("Buffer too small in _DDECallback (XTYP_EXECUTE)") );
|
||||||
|
|
||||||
@@ -848,7 +852,7 @@ _DDECallback(WORD wType,
|
|||||||
connection->OnPoke(connection->m_topicName,
|
connection->OnPoke(connection->m_topicName,
|
||||||
item_name,
|
item_name,
|
||||||
data,
|
data,
|
||||||
(int)len/sizeof(wxChar),
|
(int)len,
|
||||||
(wxIPCFormat) wFmt);
|
(wxIPCFormat) wFmt);
|
||||||
|
|
||||||
return (DDERETURN)DDE_FACK;
|
return (DDERETURN)DDE_FACK;
|
||||||
@@ -923,8 +927,9 @@ _DDECallback(WORD wType,
|
|||||||
wxString item_name = DDEStringFromAtom(hsz2);
|
wxString item_name = DDEStringFromAtom(hsz2);
|
||||||
|
|
||||||
DWORD len = DdeGetData(hData, NULL, 0, 0);
|
DWORD len = DdeGetData(hData, NULL, 0, 0);
|
||||||
|
len = ceil( static_cast<double>(len) / sizeof(wxChar) );
|
||||||
|
|
||||||
wxChar *data = connection->GetBufferAtLeast( len/sizeof(wxChar) );
|
wxChar *data = connection->GetBufferAtLeast( len );
|
||||||
wxASSERT_MSG(data != NULL,
|
wxASSERT_MSG(data != NULL,
|
||||||
_T("Buffer too small in _DDECallback (XTYP_ADVDATA)") );
|
_T("Buffer too small in _DDECallback (XTYP_ADVDATA)") );
|
||||||
|
|
||||||
@@ -934,7 +939,7 @@ _DDECallback(WORD wType,
|
|||||||
if ( connection->OnAdvise(connection->m_topicName,
|
if ( connection->OnAdvise(connection->m_topicName,
|
||||||
item_name,
|
item_name,
|
||||||
data,
|
data,
|
||||||
(int)len/sizeof(wxChar),
|
(int)len,
|
||||||
(wxIPCFormat) wFmt) )
|
(wxIPCFormat) wFmt) )
|
||||||
{
|
{
|
||||||
return (DDERETURN)(DWORD)DDE_FACK;
|
return (DDERETURN)(DWORD)DDE_FACK;
|
||||||
|
Reference in New Issue
Block a user