Skip to content

Commit

Permalink
nullptr check
Browse files Browse the repository at this point in the history
  • Loading branch information
chrchr-github committed Apr 8, 2024
1 parent 6b5a893 commit 1ad38ac
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/checkclass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3311,7 +3311,7 @@ static const Variable* getSingleReturnVar(const Scope* scope) {
const Token* const end = Token::findsimplematch(start, ";", 1, scope->bodyEnd);
if (!end || end->next() != scope->bodyEnd)
return nullptr;
if (start->str() != "return")
if (!start->astOperand1() || start->str() != "return")
return nullptr;
return start->astOperand1()->variable();
}
Expand Down
1 change: 1 addition & 0 deletions test/testclass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8985,6 +8985,7 @@ class TestClass : public TestFixture {
" T getT() const { return t; }"
" int getI() const { return i; }"
" std::string getS() const { return s; }"
" unknown_t f() { return; }"
"};");
ASSERT_EQUALS("[test.cpp:1]: (performance) Function 'getT()' should return member 't' by const reference.\n"
"[test.cpp:1]: (performance) Function 'getS()' should return member 's' by const reference.\n",
Expand Down

0 comments on commit 1ad38ac

Please sign in to comment.