| 743 | } |
| 744 | |
| 745 | void CheckBufferOverrunImpl::arrayIndexThenCheckError(const Token *tok, const std::string &indexName) |
| 746 | { |
| 747 | reportError(tok, Severity::style, "arrayIndexThenCheck", |
| 748 | "$symbol:" + indexName + "\n" |
| 749 | "Array index '$symbol' is used before limits check.\n" |
| 750 | "Defensive programming: The variable '$symbol' is used as an array index before it " |
| 751 | "is checked that is within limits. This can mean that the array might be accessed out of bounds. " |
| 752 | "Reorder conditions such as '(a[i] && i < 10)' to '(i < 10 && a[i])'. That way the array will " |
| 753 | "not be accessed if the index is out of limits.", CWE_ARRAY_INDEX_THEN_CHECK, Certainty::normal); |
| 754 | } |
| 755 | |
| 756 | //--------------------------------------------------------------------------- |
| 757 |
no test coverage detected