From 6ca4b008d056f0b39f90a7fa0191da65163cc906 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sun, 28 Feb 2010 07:26:50 +0100 Subject: [PATCH] null pointer: Fixed better error message for 'possible null pointer' + removed redundant check in our Tokenizer. --- lib/checkother.cpp | 2 +- lib/tokenize.cpp | 2 +- test/testother.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/checkother.cpp b/lib/checkother.cpp index 2f6ee86a2..d056d46bf 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -1187,7 +1187,7 @@ void CheckOther::nullPointerLinkedList() // Is this variable a pointer? const Token *tempTok = Token::findmatch(_tokenizer->tokens(), "%type% * %varid% [;)=]", varid); if (tempTok) - nullPointerError(tok1, varname); + nullPointerError(tok1, varname, tok3->linenr()); break; } diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 255b63472..8cda60d05 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -850,7 +850,7 @@ void Tokenizer::simplifyTypedef() if (tok2->str() != "}") { int level = 0; - while (tok2 && tok2->next() && (tok2->next()->str() != "}" || level)) + while (tok2->next() && (tok2->next()->str() != "}" || level)) { if (tok2->next()->str() == "{") level++; diff --git a/test/testother.cpp b/test/testother.cpp index 0c38d2794..111476976 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -670,7 +670,7 @@ private: " tok = tok->next();\n" " }\n" "}\n"); - ASSERT_EQUALS("[test.cpp:3]: (error) Possible null pointer dereference: tok\n", errout.str()); + ASSERT_EQUALS("[test.cpp:3]: (error) Possible null pointer dereference: tok - otherwise it is redundant to check if tok is null at line 5\n", errout.str()); checkNullPointer("void foo(Token &tok)\n" "{\n"