Skip to content

Commit ab04b82

Browse files
committed
valueflow.cpp: actually use the (proper) known value in valueFlowDynamicBufferSize() [skip ci]
1 parent 3ea0ea1 commit ab04b82

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

lib/valueflow.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7017,11 +7017,12 @@ static void valueFlowDynamicBufferSize(const TokenList& tokenlist, const SymbolD
70177017
sizeValue = arg1->getKnownIntValue() * arg2->getKnownIntValue();
70187018
break;
70197019
case Library::AllocFunc::BufferSize::strdup:
7020-
if (arg1 && arg1->hasKnownValue()) {
7021-
const ValueFlow::Value& value = arg1->values().back();
7022-
assert(value.isKnown());
7023-
if (value.isTokValue() && value.tokvalue->tokType() == Token::eString)
7024-
sizeValue = Token::getStrLength(value.tokvalue) + 1; // Add one for the null terminator
7020+
if (arg1) {
7021+
if (const ValueFlow::Value* value = arg1->getKnownValue(ValueFlow::Value::ValueType::TOK))
7022+
{
7023+
if (value->tokvalue->tokType() == Token::eString)
7024+
sizeValue = Token::getStrLength(value->tokvalue) + 1; // Add one for the null terminator
7025+
}
70257026
}
70267027
break;
70277028
}

0 commit comments

Comments
 (0)