Allocate more space for the wxRegEx error message buffer

We need to account for the trailing NUL explicitly here, so add 1 to the
length returned by the first call to wx_regerror() to avoid chopping off
the last character of the error message.
This commit is contained in:
Vadim Zeitlin
2021-08-04 01:29:44 +02:00
parent bdee83d5ff
commit 232a3ab577

View File

@@ -444,7 +444,7 @@ wxString wxRegExImpl::GetErrorMsg(int errorcode) const
int len = wx_regerror(errorcode, &m_RegEx, NULL, 0); int len = wx_regerror(errorcode, &m_RegEx, NULL, 0);
if ( len > 0 ) if ( len > 0 )
{ {
wxCharTypeBuffer<wxRegErrorChar> errbuf(len); wxCharTypeBuffer<wxRegErrorChar> errbuf(len + 1);
(void)wx_regerror(errorcode, &m_RegEx, errbuf.data(), errbuf.length()); (void)wx_regerror(errorcode, &m_RegEx, errbuf.data(), errbuf.length());