Skip to content

Commit 07797da

Browse files
authored
CheckBufferOverrun: bail out early in getBufferSize() (danmar#7134)
1 parent 1b807e1 commit 07797da

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

lib/checkbufferoverrun.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,7 @@ ValueFlow::Value CheckBufferOverrun::getBufferSize(const Token *bufTok) const
558558
return *value;
559559
}
560560

561-
if (!var)
561+
if (!var || var->isPointer())
562562
return ValueFlow::Value(-1);
563563

564564
const MathLib::bigint dim = std::accumulate(var->dimensions().cbegin(), var->dimensions().cend(), 1LL, [](MathLib::bigint i1, const Dimension &dim) {
@@ -571,8 +571,6 @@ ValueFlow::Value CheckBufferOverrun::getBufferSize(const Token *bufTok) const
571571

572572
if (var->isPointerArray())
573573
v.intvalue = dim * mSettings->platform.sizeof_pointer;
574-
else if (var->isPointer())
575-
return ValueFlow::Value(-1);
576574
else {
577575
const MathLib::bigint typeSize = bufTok->valueType()->typeSize(mSettings->platform);
578576
v.intvalue = dim * typeSize;

0 commit comments

Comments
 (0)