git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@43685
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
// put string back in a reasonable state after GetWriteBuf
void wxString::UngetWriteBuf()
{
// 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)
{
}
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);
// ---------------------------------------------------------------------------
// data access
// ---------------------------------------------------------------------------
// data access