Skip to content

Commit

Permalink
fixed fuzzing crashes (#6089)
Browse files Browse the repository at this point in the history
  • Loading branch information
firewave authored Mar 11, 2024
1 parent ed64e97 commit d49fd82
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 3 deletions.
3 changes: 2 additions & 1 deletion lib/checksizeof.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,8 @@ void CheckSizeof::checkSizeofForPointerSize()
continue;

// Now check for the sizeof usage: Does the level of pointer indirection match?
if (tokSize->linkAt(1)->strAt(-1) == "*") {
const Token * const tokLink = tokSize->linkAt(1);
if (tokLink && tokLink->strAt(-1) == "*") {
if (variable && variable->valueType() && variable->valueType()->pointer == 1 && variable->valueType()->type != ValueType::VOID)
sizeofForPointerError(variable, variable->str());
else if (variable2 && variable2->valueType() && variable2->valueType()->pointer == 1 && variable2->valueType()->type != ValueType::VOID)
Expand Down
4 changes: 3 additions & 1 deletion lib/tokenize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1940,7 +1940,7 @@ void Tokenizer::simplifyTypedefCpp()

// start substituting at the typedef name by replacing it with the type
Token* replStart = tok2; // track first replaced token
for (Token* tok3 = typeStart; tok3->str() != ";"; tok3 = tok3->next())
for (Token* tok3 = typeStart; tok3 && (tok3->str() != ";"); tok3 = tok3->next())
tok3->isSimplifiedTypedef(true);
if (isPointerTypeCall) {
tok2->deleteThis();
Expand Down Expand Up @@ -10537,6 +10537,8 @@ void Tokenizer::simplifyNamespaceAliases()

int endScope = scope;
Token * tokLast = tokNameEnd->next();
if (!tokLast)
return;
Token * tokNext = tokLast->next();
Token * tok2 = tokNext;

Expand Down
2 changes: 1 addition & 1 deletion lib/tokenlist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1582,7 +1582,7 @@ static Token * createAstAtToken(Token *tok)
AST_state state1(cpp);
compileExpression(tok2, state1);
if (Token::Match(init1, "( !!{")) {
for (Token *tok3 = init1; tok3 != tok3->link(); tok3 = tok3->next()) {
for (Token *tok3 = init1; tok3 && tok3 != tok3->link(); tok3 = tok3->next()) {
if (tok3->astParent()) {
while (tok3->astParent())
tok3 = tok3->astParent();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
a,typedef U typedef,U,i
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
namespace d=S
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{for(()s)}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
o k(){t*data;{memcpy(data,,sizeof\)}}

0 comments on commit d49fd82

Please sign in to comment.