We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent fec0f8d commit f70a8b2Copy full SHA for f70a8b2
1 file changed
lib/checkbufferoverrun.cpp
@@ -558,7 +558,14 @@ ValueFlow::Value CheckBufferOverrunImpl::getBufferSize(const Token *bufTok) cons
558
return ValueFlow::Value(-1);
559
if (bufTok->isUnaryOp("&"))
560
bufTok = bufTok->astOperand1();
561
- const Variable *var = bufTok->variable();
+ const Token* varTok = bufTok;
562
+ if (Token::simpleMatch(bufTok, "[")) {
563
+ const Token* index = bufTok->astOperand2();
564
+ if (!(index && index->hasKnownIntValue() && index->getKnownIntValue() == 0))
565
+ return ValueFlow::Value(-1);
566
+ varTok = varTok->astOperand1();
567
+ }
568
+ const Variable *var = varTok->variable();
569
570
if (!var || var->dimensions().empty()) {
571
const ValueFlow::Value *value = getBufferSizeValue(bufTok);
0 commit comments