Commit e960b70b authored by Kevin Funk's avatar Kevin Funk

clang: Fix severe memory leak in comment parser

Detected by ASAN:
```
Direct leak of 243151 byte(s) in 747 object(s) allocated from:
    #0 0x4e1710 in __interceptor_malloc (/home/kfunk/devel/install/kf5-stable/bin/kdevelop+0x4e1710)
    #1 0x7effd10b3221 in clang::cxstring::createDup(llvm::StringRef) /home/kfunk/devel/src/llvm/tools/clang/tools/libclang/CXString.cpp:99:40
    #2 0x7effd10b3221 in clang::cxstring::createRef(llvm::StringRef) /home/kfunk/devel/src/llvm/tools/clang/tools/libclang/CXString.cpp:89
    #3 0x7effd1292ae3 in void (anonymous namespace)::Visitor::setDeclData<(CXCursorKind)21>(CXCursor, KDevelop::ClassMemberDeclaration*) const /home/kfunk/devel/src/kf5/kdevelop-stable/plugins/clang/duchain/builder.cpp:1024:5
    #4 0x7effd1291bd0 in void (anonymous namespace)::Visitor::setDeclData<(CXCursorKind)21>(CXCursor, KDevelop::ClassFunctionDeclaration*) const /home/kfunk/devel/src/kf5/kdevelop-stable/plugins/clang/duchain/builder.cpp:1113:5
    ...
```

CCMAIL: mail@svenbrauch.de
parent 4b0201a7
......@@ -951,7 +951,7 @@ void Visitor::setDeclData(CXCursor cursor, Declaration *decl, bool setComment) c
{
if (setComment)
#if CINDEX_VERSION_MINOR < 100 // FIXME https://bugs.llvm.org/show_bug.cgi?id=35333
decl->setComment(KDevelop::formatComment(QByteArray(clang_getCString(clang_Cursor_getRawCommentText(cursor)))));
decl->setComment(KDevelop::formatComment(ClangString(clang_Cursor_getRawCommentText(cursor)).toByteArray()));
#else
decl->setComment(makeComment(clang_Cursor_getParsedComment(cursor)));
#endif
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment