diff options
author | Ivan Čukić <ivan.cukic@kdab.com> | 2022-06-21 23:21:47 +0200 |
---|---|---|
committer | Ivan Čukić <ivan.cukic@kdab.com> | 2022-06-21 23:22:25 +0200 |
commit | 3c673d922103424805b6113aaa648f3a42d5fc4f (patch) | |
tree | 3541c9afa4d1d9c8853cd7a4527f8a876bfddab5 | |
parent | 5ca2f8ce1f93c87483a0693855b2a461c9b2f3c9 (diff) |
Fix crash when Q_PROPERTY contents is empty
-rw-r--r-- | src/checks/level1/qproperty-without-notify.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/checks/level1/qproperty-without-notify.cpp b/src/checks/level1/qproperty-without-notify.cpp index 3af9fee2..47b3a72b 100644 --- a/src/checks/level1/qproperty-without-notify.cpp +++ b/src/checks/level1/qproperty-without-notify.cpp @@ -70,6 +70,13 @@ void QPropertyWithoutNotify::VisitMacroExpands(const clang::Token &MacroNameTok, CharSourceRange crange = Lexer::getAsCharRange(range, sm(), lo()); string text = static_cast<std::string>(Lexer::getSourceText(crange, sm(), lo())); + if (text.empty()) { + // If the text is empty, it is more likely there is an error + // in parsing than an empty Q_PROPERTY macro call (which would + // be a moc error anyhow). + return; + } + if (text.back() == ')') text.pop_back(); |