From 8d8fffb20f63c75bb9259a886783e1ac2eb1003a Mon Sep 17 00:00:00 2001 From: amai2012 Date: Fri, 17 Apr 2015 08:47:59 +0200 Subject: [PATCH] #6651 Don't call member function on NULL pointer - even if call is "safe" --- lib/checkuninitvar.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/checkuninitvar.cpp b/lib/checkuninitvar.cpp index bc9e0100a..3b6949128 100644 --- a/lib/checkuninitvar.cpp +++ b/lib/checkuninitvar.cpp @@ -1773,8 +1773,8 @@ bool CheckUninitVar::isVariableUsage(const Token *vartok, bool pointer, Alloc al // control-flow statement reading the variable "by value" return alloc == NO_ALLOC; } else { - bool isnullbad = _settings->library.isnullargbad(start->previous(), argumentNumber + 1); - bool isuninitbad = _settings->library.isuninitargbad(start->previous(), argumentNumber + 1); + const bool isnullbad = _settings->library.isnullargbad(start->previous(), argumentNumber + 1); + const bool isuninitbad = _settings->library.isuninitargbad(start->previous(), argumentNumber + 1); if (alloc != NO_ALLOC) return isnullbad && isuninitbad; return isuninitbad && (!address || isnullbad); @@ -1792,7 +1792,7 @@ bool CheckUninitVar::isVariableUsage(const Token *vartok, bool pointer, Alloc al do { tok2 = tok2->astOperand1(); } while (Token::simpleMatch(tok2, "<<")); - if (tok2->strAt(-1) == "::") + if (tok2 && tok2->strAt(-1) == "::") tok2 = tok2->previous(); if (tok2 && (Token::simpleMatch(tok2->previous(), "std ::") || (tok2->variable() && tok2->variable()->isStlType()) || tok2->isStandardType())) return true;