X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/bb65ef80feb05e4df68a30e1ef3786158957b00f..312cd9e93d7c0bf201e52297741e8e12a7298fc9:/src/common/string.cpp diff --git a/src/common/string.cpp b/src/common/string.cpp index da23dda0f4..29dc8d60da 100644 --- a/src/common/string.cpp +++ b/src/common/string.cpp @@ -360,8 +360,13 @@ wxString::wxString(const wchar_t *pwz) // allocates memory needed to store a C string of length nLen void wxString::AllocBuffer(size_t nLen) { - wxASSERT( nLen > 0 ); // - wxASSERT( nLen <= INT_MAX-1 ); // max size (enough room for 1 extra) + // allocating 0 sized buffer doesn't make sense, all empty strings should + // reuse g_strEmpty + wxASSERT( nLen > 0 ); + + // make sure that we don't overflow + wxASSERT( nLen < (INT_MAX / sizeof(wxChar)) - + (sizeof(wxStringData) + EXTRA_ALLOC + 1) ); STATISTICS_ADD(Length, nLen);