| 923 | } |
| 924 | |
| 925 | bool CheckBufferOverrunImpl::isCtuUnsafeBufferUsage(const Settings &settings, const Token *argtok, CTU::FileInfo::Value *offset, int type) |
| 926 | { |
| 927 | if (!offset) |
| 928 | return false; |
| 929 | if (!argtok->valueType() || argtok->valueType()->getSizeOf(settings, ValueType::Accuracy::ExactOrZero, ValueType::SizeOf::Pointee) == 0) |
| 930 | return false; |
| 931 | const Token *indexTok = nullptr; |
| 932 | if (type == 1 && Token::Match(argtok, "%name% [") && argtok->astParent() == argtok->next() && !Token::simpleMatch(argtok->linkAt(1), "] [")) |
| 933 | indexTok = argtok->next()->astOperand2(); |
| 934 | else if (type == 2 && Token::simpleMatch(argtok->astParent(), "+")) |
| 935 | indexTok = (argtok == argtok->astParent()->astOperand1()) ? |
| 936 | argtok->astParent()->astOperand2() : |
| 937 | argtok->astParent()->astOperand1(); |
| 938 | if (!indexTok) |
| 939 | return false; |
| 940 | if (!indexTok->hasKnownIntValue()) |
| 941 | return false; |
| 942 | offset->value = indexTok->getKnownIntValue() * argtok->valueType()->getSizeOf(settings, ValueType::Accuracy::ExactOrZero, ValueType::SizeOf::Pointee); |
| 943 | return true; |
| 944 | } |
| 945 | |
| 946 | bool CheckBufferOverrunImpl::isCtuUnsafeArrayIndex(const Settings &settings, const Token *argtok, CTU::FileInfo::Value *offset) |
| 947 | { |
nothing calls this directly
no test coverage detected