NUL terminate the string in UngetWriteBuf(len) (bug 1594189)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@43685 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -1077,16 +1077,21 @@ wxChar *wxString::GetWriteBuf(size_t nLen)
|
|||||||
// put string back in a reasonable state after GetWriteBuf
|
// put string back in a reasonable state after GetWriteBuf
|
||||||
void wxString::UngetWriteBuf()
|
void wxString::UngetWriteBuf()
|
||||||
{
|
{
|
||||||
GetStringData()->nDataLength = wxStrlen(m_pchData);
|
UngetWriteBuf(wxStrlen(m_pchData));
|
||||||
GetStringData()->Validate(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxString::UngetWriteBuf(size_t nLen)
|
void wxString::UngetWriteBuf(size_t nLen)
|
||||||
{
|
{
|
||||||
GetStringData()->nDataLength = nLen;
|
wxStringData * const pData = GetStringData();
|
||||||
GetStringData()->Validate(true);
|
|
||||||
|
wxASSERT_MSG( nLen < pData->nAllocLength, _T("buffer overrun") );
|
||||||
|
|
||||||
|
// the strings we store are always NUL-terminated
|
||||||
|
pData->data()[nLen] = _T('\0');
|
||||||
|
pData->nDataLength = nLen;
|
||||||
|
pData->Validate(true);
|
||||||
}
|
}
|
||||||
#endif
|
#endif // !wxUSE_STL
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
// data access
|
// data access
|
||||||
|
Reference in New Issue
Block a user