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:
Vadim Zeitlin
2006-11-27 15:03:06 +00:00
parent 269564eb1a
commit c56d73fe00

View File

@@ -1077,16 +1077,21 @@ wxChar *wxString::GetWriteBuf(size_t nLen)
// put string back in a reasonable state after GetWriteBuf
void wxString::UngetWriteBuf()
{
GetStringData()->nDataLength = wxStrlen(m_pchData);
GetStringData()->Validate(true);
UngetWriteBuf(wxStrlen(m_pchData));
}
void wxString::UngetWriteBuf(size_t nLen)
{
GetStringData()->nDataLength = nLen;
GetStringData()->Validate(true);
wxStringData * const pData = GetStringData();
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