check that the conversion really succeeds even when wxMBConv_win32::WC2MB() is called with NULL buffer
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@48643 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -2426,9 +2426,7 @@ public:
|
|||||||
return wxCONV_FAILED;
|
return wxCONV_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if we were really converting, check if we succeeded
|
// we did something, check if we really succeeded
|
||||||
if ( buf )
|
|
||||||
{
|
|
||||||
if ( flags )
|
if ( flags )
|
||||||
{
|
{
|
||||||
// check if the conversion failed, i.e. if any replacements
|
// check if the conversion failed, i.e. if any replacements
|
||||||
@@ -2438,6 +2436,19 @@ public:
|
|||||||
}
|
}
|
||||||
else // we must resort to double tripping...
|
else // we must resort to double tripping...
|
||||||
{
|
{
|
||||||
|
// first we need to ensure that we really have the MB data: this is
|
||||||
|
// not the case if we're called with NULL buffer, in which case we
|
||||||
|
// need to do the conversion yet again
|
||||||
|
wxCharBuffer bufDef;
|
||||||
|
if ( !buf )
|
||||||
|
{
|
||||||
|
bufDef = wxCharBuffer(len);
|
||||||
|
buf = bufDef.data();
|
||||||
|
if ( !::WideCharToMultiByte(m_CodePage, flags, pwz, -1,
|
||||||
|
buf, len, NULL, NULL) )
|
||||||
|
return wxCONV_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
wxWCharBuffer wcBuf(n);
|
wxWCharBuffer wcBuf(n);
|
||||||
if ( MB2WC(wcBuf.data(), buf, n) == wxCONV_FAILED ||
|
if ( MB2WC(wcBuf.data(), buf, n) == wxCONV_FAILED ||
|
||||||
wcscmp(wcBuf, pwz) != 0 )
|
wcscmp(wcBuf, pwz) != 0 )
|
||||||
@@ -2447,7 +2458,6 @@ public:
|
|||||||
return wxCONV_FAILED;
|
return wxCONV_FAILED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// see the comment above for the reason of "len - 1"
|
// see the comment above for the reason of "len - 1"
|
||||||
return len - 1;
|
return len - 1;
|
||||||
|
Reference in New Issue
Block a user