X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/bb65ef80feb05e4df68a30e1ef3786158957b00f..9f83044fb8785568e186bee64db4f98b7a9ac9c6:/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);