diff --git a/cfg/std.cfg b/cfg/std.cfg
index 52dff050b..42fc9c79d 100644
--- a/cfg/std.cfg
+++ b/cfg/std.cfg
@@ -3891,20 +3891,8 @@
-
- false
-
-
-
-
-
-
-
-
-
-
-
+
false
@@ -3917,23 +3905,8 @@
-
- false
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
false
diff --git a/lib/checkstl.cpp b/lib/checkstl.cpp
index c82c10902..9fcb1ffb9 100644
--- a/lib/checkstl.cpp
+++ b/lib/checkstl.cpp
@@ -450,21 +450,19 @@ void CheckStl::pushback()
for (const Token* tok = scope->classStart->next(); tok != scope->classEnd; tok = tok->next()) {
if (Token::Match(tok, "%var% = & %var% [")) {
// Skip it directly if it is a pointer or an array
- if (tok->tokAt(3)->variable()->isArrayOrPointer())
+ const Token* containerTok = tok->tokAt(3);
+ if (containerTok->variable() && containerTok->variable()->isArrayOrPointer())
continue;
// Variable id for pointer
const unsigned int pointerId(tok->varId());
- // Variable id for the container variable
- const unsigned int containerId(tok->tokAt(3)->varId());
-
bool invalidPointer = false;
const Token* function = nullptr;
const Token* end2 = tok->scope()->classEnd;
for (const Token *tok2 = tok; tok2 != end2; tok2 = tok2->next()) {
// push_back on vector..
- if (Token::Match(tok2, "%varid% . push_front|push_back|insert|reserve|resize|clear", containerId)) {
+ if (Token::Match(tok2, "%varid% . push_front|push_back|insert|reserve|resize|clear", containerTok->varId())) {
invalidPointer = true;
function = tok2->tokAt(2);
}
diff --git a/test/teststl.cpp b/test/teststl.cpp
index 8c232793a..c037206f5 100644
--- a/test/teststl.cpp
+++ b/test/teststl.cpp
@@ -89,6 +89,7 @@ private:
TEST_CASE(pushback10);
TEST_CASE(pushback11);
TEST_CASE(pushback12);
+ TEST_CASE(pushback13);
TEST_CASE(insert1);
TEST_CASE(insert2);
@@ -1298,6 +1299,16 @@ private:
"[test.cpp:9]: (error) After insert(), the iterator 'it' may be invalid.\n", errout.str());
}
+ void pushback13() {
+ check("bool Preprocessor::ConcatenateIncludeName(SmallString<128> &FilenameBuffer, SourceLocation &End) {\n"
+ " unsigned PreAppendSize = FilenameBuffer.size();\n"
+ " FilenameBuffer.resize(PreAppendSize + CurTok.getLength());\n"
+ " const char *BufPtr = &FilenameBuffer[PreAppendSize];\n"
+ " return true;\n"
+ "}");
+ ASSERT_EQUALS("", errout.str());
+ }
+
void insert1() {
check("void f(std::vector &ints)\n"
"{\n"