wxMaxima-developers / wxmaxima

A gui for the computer algebra system Maxima built with wxWidgets
https://wxMaxima-developers.github.io/wxmaxima/
Other
461 stars 96 forks source link

Crash when opening settings #1773

Closed alex-bel closed 1 year ago

alex-bel commented 1 year ago

I've built wxMaxima in debug mode on Windows (Visual Studio 2022, x64) and it always crashes with "Debug Assertion Failed!" on attempt to open Settings dialog: image

Stack trace: image

The problem is in EditorCell::FindMatchingParens():

void EditorCell::FindMatchingParens() {
  m_paren1 = m_paren2 = -1;
  if (m_positionOfCaret < 0)
    return;

  wxChar charUnderCursor = m_text.GetChar(m_positionOfCaret);  //m_text is "" and m_positionOfCaret is 0, so we are trying to get 0th char of an empty string
  if (charUnderCursor == wxT('\"')) {
    FindMatchingQuotes();
    return;
  }

Sounds like an extra check m_positionOfCaret < m_text.Length() should be added before that line