From a51e012a5a89ac8d27b9f8956e8038f0f89c8513 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sun, 17 Feb 2008 17:22:21 +0000 Subject: [PATCH] Added list of bugs that cppcheck find (incomplete) --- bugs_that_cppcheck_finds.txt | 57 ++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 bugs_that_cppcheck_finds.txt diff --git a/bugs_that_cppcheck_finds.txt b/bugs_that_cppcheck_finds.txt new file mode 100644 index 000000000..711c61f0d --- /dev/null +++ b/bugs_that_cppcheck_finds.txt @@ -0,0 +1,57 @@ + +List of bugs that c++check finds + + + +Buffer overrun: + + // using numeric array index + char str[100]; + str[100] = 0; + + // using constant array index + char str2[SIZE]; + str[SIZE] = 0; + + // Calculating array index with constants and numbers + int i[100]; + i[sizeof(i)-1] = 0; + + // In some cases, it's detected when a variable causes buffer overrun: + char str[100]; + for (int i = 0; i <= 100; i++) + str[i] = 0; + + // Using 'strcpy' and 'strcat' can result in buffer overrun.. + char str[3]; + strcpy(str, "abc"); + + + +Memory leaks: + + // No deallocation at all + { + Fred *fred = new Fred; + } + + // Mismatching allocation / deallocation + char *str = new char[10]; + delete str; // Should be 'delete [] str' + + // An execution path may prevent a variable from being deallocated: + char *str = new char[10]; + if (ab == cd) + return; // or 'continue' or 'break' + + + +Class constructors: + + Check that all member variables are initialized. + + Check that all private member functions are used. + + + +