Skip to content

Commit

Permalink
fixed fuzzing crash
Browse files Browse the repository at this point in the history
/home/user/CLionProjects/cppcheck-rider/lib/checkassert.cpp:132:53: runtime error: member call on null pointer of type 'Token'
    #0 0x63f3e941d85a in CheckAssert::checkVariableAssignment(Token const*, Scope const*) /home/user/CLionProjects/cppcheck-rider/lib/checkassert.cpp:132:53
    #1 0x63f3e941c846 in CheckAssert::assertWithSideEffects() /home/user/CLionProjects/cppcheck-rider/lib/checkassert.cpp:58:13
    #2 0x63f3e941f243 in CheckAssert::runChecks(Tokenizer const&, ErrorLogger*) /home/user/CLionProjects/cppcheck-rider/lib/checkassert.h:54:21
    #3 0x63f3e9aa04cd in CppCheck::checkNormalTokens(Tokenizer const&) /home/user/CLionProjects/cppcheck-rider/lib/cppcheck.cpp:1124:20
    #4 0x63f3e9ab94ab in CppCheck::checkFile(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::istream*) /home/user/CLionProjects/cppcheck-rider/lib/cppcheck.cpp:957:17
    #5 0x63f3e9aa6a97 in CppCheck::check(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&) /home/user/CLionProjects/cppcheck-rider/lib/cppcheck.cpp:556:12
    #6 0x63f3e8ba4f2b in SingleExecutor::check() /home/user/CLionProjects/cppcheck-rider/cli/singleexecutor.cpp:53:29
    #7 0x63f3e8adf8dc in CppCheckExecutor::check_internal(Settings const&) const /home/user/CLionProjects/cppcheck-rider/cli/cppcheckexecutor.cpp:277:32
    #8 0x63f3e8ade73d in CppCheckExecutor::check_wrapper(Settings const&) /home/user/CLionProjects/cppcheck-rider/cli/cppcheckexecutor.cpp:216:12
    #9 0x63f3e8add67a in CppCheckExecutor::check(int, char const* const*) /home/user/CLionProjects/cppcheck-rider/cli/cppcheckexecutor.cpp:202:21
    #10 0x63f3ea1ee2b7 in main /home/user/CLionProjects/cppcheck-rider/cli/main.cpp:91:21
    #11 0x7a2c9501eccf  (/usr/lib/libc.so.6+0x29ccf) (BuildId: 0865c4b9ba13e0094e8b45b78dfc7a2971f536d2)
    #12 0x7a2c9501ed89 in __libc_start_main (/usr/lib/libc.so.6+0x29d89) (BuildId: 0865c4b9ba13e0094e8b45b78dfc7a2971f536d2)
    #13 0x63f3e89189f4 in _start (/home/user/CLionProjects/cppcheck-rider/cmake-build-debug-clang-asan-ubsan/bin/cppcheck+0xf6e9f4) (BuildId: 5c2986a23a9dee600c328566a7967a7eba8652c9)
  • Loading branch information
firewave committed Mar 6, 2024
1 parent e93b031 commit 4fb1dc1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/checkassert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ void CheckAssert::checkVariableAssignment(const Token* assignTok, const Scope *a
if (!assignTok->isAssignmentOp() && assignTok->tokType() != Token::eIncDecOp)
return;

if (!assignTok->astOperand1())
return;

const Variable* var = assignTok->astOperand1()->variable();
if (!var)
return;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
assert({=;})

0 comments on commit 4fb1dc1

Please sign in to comment.