Skip to content
  • Erik Verbruggen's avatar
    C++: Fix possible use-after-free of AST. · c8c2aaaf
    Erik Verbruggen authored
    
    
    The CppRefactoringChanges::fileNoEditor takes a Document from the
    snapshot it has. Although this snapshot is a safe copy, it might have
    been gotten right after it was updated by indexing. Such a document will
    still have its AST. If this AST is used by any refactoring action
    without retaining it, the pointers will be dangling after a short while
    (specifically: after the locator has extracted all the information).
    
    The fileNoEditor method is called by the declDefLinkFinder to search
    the target document. The snapshot is obtained before, and contains the
    document for the semantic info. However, the target document will not
    come from the semantic info, but from the indexer.
    
    Change-Id: I212ff41dde6910e94e80552b2c3e5911fe9496ae
    Task-number: QTCREATORBUG-11262
    Reviewed-by: default avatarNikolai Kosjar <nikolai.kosjar@digia.com>
    c8c2aaaf