diff --git a/src/checkother.cpp b/src/checkother.cpp index 491439cea..94249b9b3 100644 --- a/src/checkother.cpp +++ b/src/checkother.cpp @@ -832,10 +832,7 @@ void CheckOther::strPlusChar() } - - - -void CheckOther::nullPointer() +void CheckOther::nullPointerAfterLoop() { // Locate insufficient null-pointer handling after loop for (const Token *tok = _tokenizer->tokens(); tok; tok = tok->next()) @@ -891,7 +888,10 @@ void CheckOther::nullPointer() tok2 = tok2->next(); } } +} +void CheckOther::nullPointerLinkedList() +{ // looping through items in a linked list in a inner loop.. for (const Token *tok1 = _tokenizer->tokens(); tok1; tok1 = tok1->next()) { @@ -969,6 +969,10 @@ void CheckOther::nullPointer() } } } +} + +void CheckOther::nullPointerStructByDeRefAndChec() +{ // Dereferencing a struct pointer and then checking if it's NULL.. for (const Token *tok1 = _tokenizer->tokens(); tok1; tok1 = tok1->next()) @@ -1047,6 +1051,10 @@ void CheckOther::nullPointer() } } +} + +void CheckOther::nullPointerByDeRefAndChec() +{ // Dereferencing a pointer and then checking if it's NULL.. for (const Token *tok = _tokenizer->tokens(); tok; tok = tok->next()) { @@ -1093,7 +1101,13 @@ void CheckOther::nullPointer() } } - +void CheckOther::nullPointer() +{ + nullPointerAfterLoop(); + nullPointerLinkedList(); + nullPointerStructByDeRefAndChec(); + nullPointerByDeRefAndChec(); +} void CheckOther::checkZeroDivision() { diff --git a/src/checkother.h b/src/checkother.h index 62377fab0..513ad2ff7 100644 --- a/src/checkother.h +++ b/src/checkother.h @@ -202,6 +202,32 @@ public: // optimisations " * optimisation: detect post increment/decrement\n"; } + +private: + + /** + * Does one part of the check for nullPointer(). + * Locate insufficient null-pointer handling after loop + */ + void nullPointerAfterLoop(); + + /** + * Does one part of the check for nullPointer(). + * looping through items in a linked list in a inner loop.. + */ + void nullPointerLinkedList(); + + /** + * Does one part of the check for nullPointer(). + * Dereferencing a struct pointer and then checking if it's NULL.. + */ + void nullPointerStructByDeRefAndChec(); + + /** + * Does one part of the check for nullPointer(). + * Dereferencing a pointer and then checking if it's NULL.. + */ + void nullPointerByDeRefAndChec(); }; /// @} //---------------------------------------------------------------------------