Skip to content

Commit 95235ca

Browse files
authored
add test/cli/fuzz_test.py to easily integrate oss-fuzz findings into tests (#5985)
This adds a Python test which processes input files from a folder and checks that they do not cause any crashes. This will later be extended to include timeouts as well.
1 parent 23d3f5c commit 95235ca

11 files changed

Lines changed: 33 additions & 5 deletions

lib/checkfunctions.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -766,7 +766,7 @@ void CheckFunctions::useStandardLibrary()
766766
continue;
767767

768768
// 3. we expect idx incrementing by 1
769-
const bool inc = stepToken->str() == "++" && stepToken->astOperand1()->varId() == idxVarId;
769+
const bool inc = stepToken->str() == "++" && stepToken->astOperand1() && stepToken->astOperand1()->varId() == idxVarId;
770770
const bool plusOne = stepToken->isBinaryOp() && stepToken->str() == "+=" &&
771771
stepToken->astOperand1()->varId() == idxVarId &&
772772
stepToken->astOperand2()->str() == "1";

lib/checkother.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1938,7 +1938,7 @@ void CheckOther::checkIncompleteStatement()
19381938
continue;
19391939
if (isVoidStmt(tok))
19401940
continue;
1941-
if (mTokenizer->isCPP() && tok->str() == "&" && !(tok->astOperand1()->valueType() && tok->astOperand1()->valueType()->isIntegral()))
1941+
if (mTokenizer->isCPP() && tok->str() == "&" && !(tok->astOperand1() && tok->astOperand1()->valueType() && tok->astOperand1()->valueType()->isIntegral()))
19421942
// Possible archive
19431943
continue;
19441944
const bool inconclusive = tok->isConstOp();

lib/checkuninitvar.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1287,7 +1287,7 @@ const Token* CheckUninitVar::isVariableUsage(const Token *vartok, const Library&
12871287
if (Token::Match((derefValue ? derefValue : vartok)->astParent(), "(|=") && astIsRhs(derefValue ? derefValue : vartok)) {
12881288
const Token *rhstok = derefValue ? derefValue : vartok;
12891289
const Token *lhstok = rhstok->astParent()->astOperand1();
1290-
const Variable *lhsvar = lhstok->variable();
1290+
const Variable *lhsvar = lhstok ? lhstok->variable() : nullptr;
12911291
if (lhsvar && lhsvar->isReference() && lhsvar->nameToken() == lhstok)
12921292
return nullptr;
12931293
}

lib/programmemory.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ void programMemoryParseCondition(ProgramMemory& pm, const Token* tok, const Toke
320320
else
321321
pm.setIntValue(tok, 0, then);
322322
}
323-
} else if (tok->exprId() > 0) {
323+
} else if (tok && tok->exprId() > 0) {
324324
if (endTok && findExpressionChanged(tok, tok->next(), endTok, settings, true))
325325
return;
326326
pm.setIntValue(tok, 0, then);

lib/tokenlist.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -960,7 +960,7 @@ static void compilePrecedence2(Token *&tok, AST_state& state)
960960
Token* const curlyBracket = squareBracket->link()->next();
961961
squareBracket->astOperand1(curlyBracket);
962962
state.op.push(squareBracket);
963-
tok = curlyBracket->link()->next();
963+
tok = curlyBracket->link() ? curlyBracket->link()->next() : nullptr;
964964
continue;
965965
}
966966
}
18 Bytes
Binary file not shown.
103 Bytes
Binary file not shown.
106 Bytes
Binary file not shown.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#include <?ector>
2+
sho main()
3+
{
4+
std::veCtor<inv> items(2);
5+
stdtryector<int>::iterator iter;
6+
for (iter -= items.begin(); i&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&ter != items.end();) {
7+
if (*iter == 2) {
8+
iter = items.erase//(iter);
9+
} else {
10+
}
11+
}
12+
}
159 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)