Restored functionality to detect std::string(0) calls as null pointer dereferences (#6189)
This commit is contained in:
parent
7107286be6
commit
a99fd364ef
|
@ -431,7 +431,7 @@ void CheckNullPointer::nullConstantDereference()
|
|||
ovar = tok->variable();
|
||||
else if (Token::Match(tok, "%var% =|+ 0 )|]|,|;|+"))
|
||||
ovar = tok->variable();
|
||||
if (ovar && !ovar->isPointer() && !ovar->isArray() && ovar->isStlStringType() && !tok->tokAt(2)->isLiteral())
|
||||
if (ovar && !ovar->isPointer() && !ovar->isArray() && ovar->isStlStringType() && tok->tokAt(2)->originalName() != "'\\0'")
|
||||
nullPointerError(tok);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2026,6 +2026,8 @@ private:
|
|||
"}", true);
|
||||
ASSERT_EQUALS("[test.cpp:9]: (error) Possible null pointer dereference: p\n"
|
||||
"[test.cpp:10]: (error) Possible null pointer dereference: p\n"
|
||||
"[test.cpp:3]: (error) Null pointer dereference\n"
|
||||
"[test.cpp:5]: (error) Null pointer dereference\n"
|
||||
"[test.cpp:7]: (error) Null pointer dereference\n"
|
||||
"[test.cpp:8]: (error) Null pointer dereference\n"
|
||||
/* TODO: handle std::string
|
||||
|
|
Loading…
Reference in New Issue