diff --git a/include/wx/vector.h b/include/wx/vector.h index b34b46c7ed..68150d3774 100644 --- a/include/wx/vector.h +++ b/include/wx/vector.h @@ -519,6 +519,15 @@ public: const size_t idx = it - begin(); const size_t after = end() - it; + // Unfortunately gcc 12 still complains about use-after-free even + // though our code is correct because it actually optimizes it to be + // wrong, with -O2 or higher, by moving the assignment above below the + // call to reserve() below, so use this hack to avoid the warning with + // it by preventing it from rearranging the code. +#if wxCHECK_GCC_VERSION(12, 1) + __asm__ __volatile__("":::"memory"); +#endif + reserve(size() + count); // the place where the new element is going to be inserted diff --git a/src/stc/scintilla/lexers/LexDMIS.cxx b/src/stc/scintilla/lexers/LexDMIS.cxx index 7eeecca0e5..0493a69cab 100644 --- a/src/stc/scintilla/lexers/LexDMIS.cxx +++ b/src/stc/scintilla/lexers/LexDMIS.cxx @@ -244,10 +244,10 @@ void SCI_METHOD LexerDMIS::Lex(Sci_PositionU startPos, Sci_Position lengthDoc, i case SCE_DMIS_KEYWORD: if (!setDMISWord.Contains(scCTX.ch)) { - char tmpStr[MAX_STR_LEN]; - memset(tmpStr, 0, MAX_STR_LEN*sizeof(char)); - scCTX.GetCurrent(tmpStr, (MAX_STR_LEN-1)); - strncpy(tmpStr, this->UpperCase(tmpStr), (MAX_STR_LEN-1)); + char tmpBuf[MAX_STR_LEN]; + memset(tmpBuf, 0, MAX_STR_LEN*sizeof(char)); + scCTX.GetCurrent(tmpBuf, (MAX_STR_LEN-1)); + char* const tmpStr = this->UpperCase(tmpBuf); if (this->m_minorWords.InList(tmpStr)) { scCTX.ChangeState(SCE_DMIS_MINORWORD);