Skip to content
  • Oliver Kellogg's avatar
    Fix crash reported in https://bugs.kde.org/show_bug.cgi?id=338649#c20 · 7d3eb053
    Oliver Kellogg authored
    related to multiple calls of m_source.unicode() where the calls return
    different address values.
    The solution is to call m_source.unicode() only once:
    
    lib/cppparser/lexer.h
    - In class Lexer add private member m_src of type const QChar*.
    
    lib/cppparser/lexer.cpp
    - In function Lexer::setSource,
      - assign m_source.unicode() to m_src;
      - if m_source.isEmpty() returns true then return without calling
        tokenize().
    - In function Lexer::reset initialize m_src to null pointer.
    - In function Lexer::offset return m_src + offset.
    - In function Lexer::getOffset use m_src in lieu of src.
      This avoids the second call to m_source.unicode() which on newer Qt5
      versions may return a different buffer.
    
    CCBUG: 338649
    7d3eb053