| 1132 | } |
| 1133 | |
| 1134 | void CheckBufferOverrunImpl::objectIndexError(const Token *tok, const ValueFlow::Value *v, bool known) |
| 1135 | { |
| 1136 | ErrorPath errorPath; |
| 1137 | std::string name; |
| 1138 | if (v) { |
| 1139 | const Token* expr = v->tokvalue; |
| 1140 | while (Token::simpleMatch(expr->astParent(), ".")) |
| 1141 | expr = expr->astParent(); |
| 1142 | name = expr->expressionString(); |
| 1143 | errorPath = v->errorPath; |
| 1144 | } |
| 1145 | errorPath.emplace_back(tok, ""); |
| 1146 | std::string verb = known ? "is" : "might be"; |
| 1147 | reportError(std::move(errorPath), |
| 1148 | known ? Severity::error : Severity::warning, |
| 1149 | "objectIndex", |
| 1150 | "The address of variable '" + name + "' " + verb + " accessed at non-zero index.", |
| 1151 | CWE758, |
| 1152 | Certainty::normal); |
| 1153 | } |
| 1154 | |
| 1155 | static bool isVLAIndex(const Token* tok) |
| 1156 | { |
no test coverage detected