From f0c1d49abfa1c5f1562e108026993d2bfb7e4ed2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sat, 11 Aug 2018 14:45:12 +0200 Subject: [PATCH] Fix Cppcheck warning --- lib/checkstl.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/checkstl.cpp b/lib/checkstl.cpp index 4aafb0122..4c5297f54 100644 --- a/lib/checkstl.cpp +++ b/lib/checkstl.cpp @@ -111,7 +111,7 @@ void CheckStl::outOfBoundsError(const Token *tok, const ValueFlow::Value *contai errmsg = "Accessing an item in container '$symbol'. " + ValueFlow::eitherTheConditionIsRedundant(containerSize->condition) + " or '$symbol' can be empty."; else errmsg = "Accessing an item in container '$symbol' that is empty."; - } else { + } else if (index) { if (containerSize->condition || index->condition) errmsg = "Possible access out of bounds"; else @@ -120,6 +120,9 @@ void CheckStl::outOfBoundsError(const Token *tok, const ValueFlow::Value *contai errmsg += " of container '$symbol'; size=" + MathLib::toString(containerSize->intvalue) + ", index=" + MathLib::toString(index->intvalue); + } else { + // should not happen + return; } ErrorPath errorPath;