Skip to content

Commit 16d3369

Browse files
Update checkstl.cpp
1 parent dc9bd7f commit 16d3369

1 file changed

Lines changed: 5 additions & 14 deletions

File tree

lib/checkstl.cpp

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -259,20 +259,11 @@ void CheckStlImpl::outOfBoundsError(const Token *tok, const std::string &contain
259259
return;
260260
}
261261

262-
ErrorPath errorPath;
263-
if (!indexValue)
264-
errorPath = getErrorPath(tok, containerSize, "Access out of bounds");
265-
else {
266-
ErrorPath errorPath1 = getErrorPath(tok, containerSize, "Access out of bounds");
267-
ErrorPath errorPath2 = getErrorPath(tok, indexValue, "Access out of bounds");
268-
if (errorPath1.size() <= 1)
269-
errorPath = std::move(errorPath2);
270-
else if (errorPath2.size() <= 1)
271-
errorPath = std::move(errorPath1);
272-
else {
273-
errorPath = std::move(errorPath1);
274-
errorPath.splice(errorPath.end(), errorPath2);
275-
}
262+
ErrorPath errorPath = getErrorPath(tok, containerSize, "Access out of bounds");
263+
if (indexValue) {
264+
ErrorPath errorPathIdx = getErrorPath(tok, indexValue, "Access out of bounds");
265+
if (errorPathIdx.size() >= errorPath.size())
266+
errorPath = std::move(errorPathIdx);
276267
}
277268

278269
reportError(std::move(errorPath),

0 commit comments

Comments
 (0)