Skip to content

Commit

Permalink
CheckBufferOverrun: bail out early in getBufferSize()
Browse files Browse the repository at this point in the history
  • Loading branch information
firewave committed Dec 28, 2024
1 parent 1b807e1 commit 1085885
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions lib/checkbufferoverrun.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ ValueFlow::Value CheckBufferOverrun::getBufferSize(const Token *bufTok) const
return *value;
}

if (!var)
if (!var || var->isPointer())
return ValueFlow::Value(-1);

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

if (var->isPointerArray())
v.intvalue = dim * mSettings->platform.sizeof_pointer;
else if (var->isPointer())
return ValueFlow::Value(-1);
else {
const MathLib::bigint typeSize = bufTok->valueType()->typeSize(mSettings->platform);
v.intvalue = dim * typeSize;
Expand Down

0 comments on commit 1085885

Please sign in to comment.