Commit Graph

616 Commits

Author SHA1 Message Date
Frank Zingsheim 9497732ac8 Fixed #6238 (false positive with double fopen) 2014-11-20 22:19:39 +01:00
Daniel Marjamäki 051d42ae6b astyle formatting 2014-11-20 14:20:09 +01:00
orbitcowboy f5d804f71a running astyle 2014-11-20 10:13:03 +01:00
Daniel Marjamäki 8012ac9562 Fixed #5993 (FP: memleak (linux list)) 2014-11-07 07:44:12 +01:00
PKEuS 6955e719cf Collected garbage code tests and moved them to testgarbage.cpp 2014-10-16 10:59:46 +02:00
PKEuS 7c7fcf36af Support :: prefix in front of allocation function. 2014-10-01 15:33:03 +02:00
PKEuS 8788e58cbb Fixed false positive #5327: fclose as inner function call 2014-09-30 13:55:21 +02:00
PKEuS c0e2adf723 Detect "var += fclose(f)" as deallocation (fixes false positive #6016) 2014-09-30 13:19:53 +02:00
PKEuS e1218cf846 Support allocation of array of pointers with operator new in checkmemoryleak.cpp 2014-09-27 11:25:08 +02:00
PKEuS 0a416910c4 Improved speed of testrunner: Avoid repeated loading of the same library 2014-09-10 20:29:44 +02:00
PKEuS 2d608890a5 Improved message 'mismatchSize' (#4167) 2014-09-02 09:38:40 +02:00
PKEuS 40e5dab9dc Refactorization in checkmemoryleak.cpp:
- Use Library to detect noreturn/notnoreturn functions
- Removed realloc from std.cfg as long as there is no proper way to configure such functions
2014-09-01 13:54:33 +02:00
Pierre Schweitzer 1cf2e36dd5 Add a new test for OpenFile function from windows.cfg.
It is here as a reminder for a TODO. When used with OF_EXIST flag, the function OpenFile doesn't return a handle and thus, doesn't leak any resource.
As cppcheck doesn't support such feature yet, it's added a TODO not to be forgotten for later fix when cppcheck supports this.

Also added a naive check, just to ensure the OpenFile check doesn't get broken when adding support for OF_EXIST.
2014-06-01 00:00:49 +02:00
PKEuS 01a0154daa Fixed false positive #5848 2014-05-21 13:45:36 +02:00
Simon Martin 512e22d1ba Ticket #5315: Memory leak analysis confused by ((variable).attribute) notation. 2014-05-08 20:58:24 +02:00
Daniel Marjamäki 44a66e6a5a Fixed #1416 (false negative resource leak when calling fdopen) 2014-04-20 10:50:32 +02:00
Daniel Marjamäki a9943fe6d0 Fixed #5525 (Closing a socket file descriptor gives an error: Mismatching allocation and deallocation) 2014-04-18 17:05:44 +02:00
Robert Reif 7eb3988415 Fixed #5659 (False negative: mismatching allocation / deallocation whith using namespace) 2014-04-11 05:40:37 +02:00
Robert Reif 4ae204e46b Fixed #5659 (False negative: mismatching allocation / deallocation whith using namespace) 2014-04-10 16:11:11 +02:00
Daniel Marjamäki d7e2e3bd5e Fixed #5502 (FP: Dereferencing 'b' after it is deallocated / released) 2014-04-06 18:45:24 +02:00
PKEuS d4765bccc3 Refactorized inefficient usage of std::string and const char[] (part 2). 2014-04-03 14:56:14 +02:00
PKEuS e9411e05ba Refactorized inefficient usage of std::string and const char[]. 2014-04-02 13:56:34 +02:00
PKEuS 7e4081f7f5 Treat syntaxError and cppcheckError as InternalErrors (throw as exception, #4268) 2014-03-27 13:15:21 +01:00
PKEuS 9b4b90f6a0 Avoid loading libraries multiple times in test suite
-> Massive speedup for test suite (especially on slow systems)
2014-03-24 09:59:05 +01:00
Daniel Marjamäki 06618b31bb Fixed #5574 (False positive: mismatchAllocDealloc using realloc() and free) 2014-03-17 16:10:54 +01:00
Daniel Marjamäki 23efc68dd7 use nullptr 2014-02-16 10:32:10 +01:00
Daniel Marjamäki fd3a8a2a18 Update copyright 2014-02-15 07:45:39 +01:00
Pavel Roschin df69f4e4be Library: add mk[sd]temp to Posix 2014-02-11 17:02:33 +04:00
Daniel Marjamäki 8305015dea astyle formatting 2014-02-08 08:51:38 +01:00
Pavel Roschin 19a8cfd960 Library: add new "define" tag
This tag will allow to add some preprocessor defs into library.
It would be useful to provide more information about libraries
implementation details. As example GLib's library include tag
was added that helps to detect more memory leaks.
2014-02-07 10:13:36 +04:00
Daniel Marjamäki 3c0619cba5 astyle formatting 2014-02-05 18:49:34 +01:00
Pavel Roschin 4f38d7ae31 Library: add full GLib/GTK support 2014-02-05 19:52:24 +04:00
Pavel Roschin 0dd227419d CheckMemoryLeak: use library while checking whitelist functions 2014-02-05 12:16:50 +04:00
Daniel Marjamäki 8c40f4fee0 astyle formatting 2014-02-03 18:51:07 +01:00
Daniel Marjamäki ed4fa9f154 Merge pull request #231 from scriptum/rpg-add-glib-tests
Add GLib library, add GLib tests (some new bugs found)
2014-02-02 10:49:33 -08:00
Pavel Roschin 651ebcf17b Add GLib library, add GLib tests (some new bugs found) 2014-02-02 22:45:57 +04:00
Pavel Roschin e06e96e864 Added regression for #3236 (Failure to detect memory leak if pointer members are added) 2014-02-01 15:51:29 +04:00
Daniel Marjamäki 30b56437c1 Merge pull request #226 from scriptum/rpg-fix-function-parameter
CheckMemoryLeak: improve leak checking in function parameters
2014-01-28 20:32:56 -08:00
Pavel Roschin 2396073262 CheckMemoryLeak: improve leak checking in function parameters 2014-01-28 17:30:36 +04:00
Daniel Marjamäki 6e6de82323 CheckMemoryLeak: test alloc/dealloc configuration in posix.cfg 2014-01-27 16:51:18 +01:00
Daniel Marjamäki 2b8cf462c9 CheckMemoryLeak: Move posix-opendir/closedir to library 2014-01-26 17:02:36 +01:00
Simon Martin 6019f45249 Ticket #5201: Get rid of internal error when checking valid C input for memory leaks. 2014-01-03 23:27:56 +01:00
Zachary Blair 7a6386bc4b Fixed #4867 (Memory Leak: Return value of malloc) 2014-01-03 10:12:32 +01:00
PKEuS 4f0121ee2f Splitted simplification out of tokenize() 2013-12-30 17:45:28 +01:00
Daniel Marjamäki e13aa0dbc3 Fixed #5275 (FP mismatchAllocDealloc: user defined opendir()/closedir() on non-POSIX system) 2013-12-29 09:51:29 +01:00
Daniel Marjamäki 57ecdd693c Fixed #5149 (false positive: (error) Dereferencing 'memory' after it is deallocated / released) 2013-12-14 07:37:24 +01:00
Alexander Mai 6eab4abaf2 Fixed #5030 (Segmentation fault below CheckMemoryLeakStructMember::isMalloc()) 2013-09-21 18:10:29 +02:00
PKEuS a9a5dc0354 Updated to AStyle 2.03, require this version 2013-08-07 16:27:37 +02:00
Daniel Marjamäki 807204e580 Fixed #4237 (False positive: (error) Memory Leak: data (references and pointer aliases)) 2013-07-30 11:30:14 +02:00
Daniel Marjamäki 61e1dd5096 Environment: Refactoring and cleanup 2013-07-05 20:55:31 +02:00
Daniel Marjamäki 1a35241aa2 testrunner: removed redundant ';' 2013-06-30 19:44:12 +02:00
Daniel Marjamäki 582e0ee7e7 testrunner: Added REGISTER_TEST. Thanks lucasmrod. 2013-06-30 19:42:26 +02:00
Daniel Marjamäki 6b2bab535b CLI,LIB: Added --std setting for GTK 2013-06-29 12:55:24 +02:00
Daniel Marjamäki ae7363fe54 Fixed #4599 (False positive with fopen/fclose test) 2013-05-23 06:34:22 +02:00
Daniel Marjamäki cf75e2bb28 astyle formatting 2013-04-30 06:44:50 +02:00
Baris Demiray 548dd42aaf Fixed #933 (Leaks with struct members not detected) 2013-04-26 16:11:57 +02:00
XhmikosR 700512a53f use spaces in strings 2013-04-09 17:49:09 +02:00
Ettl Martin 3e8eddc69e cleanup testcases: moved testcases from #3888 into allocfunc13 which contains similar testcases already. 2013-04-03 10:12:36 +02:00
Ettl Martin 9f25b618dc #3888 added a testcase 2013-04-03 08:57:26 +02:00
Ettl Martin 1b9c1c03fa unittests: removed not needed '\n' at the end of testcases. 2013-03-20 15:36:16 +01:00
PKEuS 14feaa8d39 Refactorizations:
- Fixed lots of cppcheck messages about functions that can be const or static
- Fixed possible nullpointer dereference message in symboldatabase.cpp
- Replaced tokAt(+-1) by next()/previous()
2013-03-12 07:42:00 -07:00
PKEuS d78c06dc3f Replaced _settings->isEnabled("style") by _settings->isEnabled("warning") wherever warnings are issued 2013-03-03 02:41:59 -08:00
Daniel Marjamäki 2edf95a1b9 Fixed #4367 (false positive: Class '...' is unsafe, '...' can leak by wrong usage) 2013-02-24 08:14:25 +01:00
Frank Zingsheim 5144307642 Raise syntax error for if-condition without parentheses according to #2518 #4171 2013-02-05 21:13:57 +01:00
Daniel Marjamäki bd7e3cbac5 Fixed #4540 (memory leak not detected ('.' or '->' is used before Function)) 2013-01-31 17:00:50 +01:00
Frank Zingsheim 6dc9987ad0 Fixed #4517 (Testmemleak should not use Tokenizer on pseudo code) 2013-01-27 02:41:43 +01:00
Daniel Marjamäki f86e83d813 Memory leaks: Improved handling of allocation functions that contains ::. Ticket: #4494 2013-01-22 21:33:39 +01:00
Reijo Tomperi 5d5f7085bf Updating year 2012 -> 2013 to .cpp and .h files and man page. 2013-01-01 18:29:08 +02:00
Daniel Marjamäki a84d21f271 CheckMemoryLeaksInFunction: Fixed problems with catch and function calls. Ticket: #4405 2012-12-16 18:06:40 +01:00
Frank Zingsheim 327db15284 Fix #4045: memory leak not reported after usage of " + p[]" 2012-12-09 08:59:21 +01:00
PKEuS 4737966caf Unit test cleanup: Removed some empty lines and whitespaces before \n. 2012-12-06 10:19:22 -08:00
PKEuS 36aeb74b5a Fixed string literals in several unit tests (one test failing - changed it to TODO) 2012-11-29 21:07:52 +01:00
Daniel Marjamäki 38213f1f2f Fixed #4237 (False positive: (error) Memory Leak: data (assign reference variable value to a shadow variable in inner scope)) 2012-10-27 16:36:14 +02:00
Daniel Marjamäki 863441afe8 Fixed #4236 (False positive: pointer free()d twice - neglecting call to other function) 2012-10-25 19:41:18 +02:00
PKEuS 22a8e3f4e6 Replaced Tokenizer::getFunctionTokenByName() by SymbolDatabase::findFunctionByName(), which handles scopes slightly better. 2012-09-11 18:03:47 +02:00
Daniel Marjamäki 54f1771938 Fixed #4082 (Maybe false positive: memleak) 2012-09-10 17:27:41 +02:00
Daniel Marjamäki 2a9eaebcaa replaced tabs with spaces 2012-09-05 20:50:25 +02:00
PKEuS 1fbaae948c Added regression test cases for #404. 2012-08-26 11:39:17 +02:00
PKEuS 35d94c26d5 Changed creation of SymbolDatabase. Database always created after Tokenizer::tokenize() and Tokenizer::simplifyTokenList() instead of on-demand creation by Tokenizer::getSymbolDatabase.
-> With Token::scope() it is possible to access the symboldatabase without having to call getSymbolDatabase(). The change increases safety because it is guaranteed that the database is available in all checks, even if the specific check doesn't call getSymbolDatabase
- Tokenizer::_symbolDatabase does no longer have to be mutable -> Increased const correctness

The change above required two additional changes:
- A bug causing a debug message was fixed in the symboldatabase that became visible in the test suite by the change above.
- Simplify expressions like "struct struct Foo" which might be result of typedef instanciation.
2012-08-12 03:01:24 -07:00
PKEuS 45bad7d1b2 Refactorized tokenizer:
- Don't run setVarId() twice, keep old varId's while/after simplifyTokenList
-> Modified two test cases in testmemleak.cpp. I consider this to be safe. Feel free to investigate this.
- Fixed two nullpointer issues shown by cppcheck

Ran Astyle on teststl.cpp
2012-08-10 09:31:22 -07:00
PKEuS 003a9be3ed Refactorizations: Made several test functions const according to cppcheck messages. 2012-08-02 02:13:09 -07:00
PKEuS 78bc4ddbad Fixed unusedFunctions warnings emmitted by cppcheck:
- Several tests in testcmdlineparser.cpp were never executed (failing tests commented)
- Unnecessary function in testmemleak.cpp removed.
2012-08-01 11:18:03 -07:00
Daniel Marjamäki 0ead18122d Fixed #3695 (False positive: memory leak (ptr?free(ptr):0)) 2012-07-27 12:25:20 +02:00
Daniel Marjamäki e6f761126c Fixed #2802 (False positive: ::free() is not recognised as free() to release buffers) 2012-07-24 09:28:08 +02:00
Daniel Marjamäki a768b0e8b2 Fixed #3954 (Pointer reference memory leak false positive) 2012-07-17 16:28:34 +02:00
PKEuS 2103811291 Refactorizations in testrunner:
- Removed unnecessary space characters
- Removed comments from test cases which are not preprocessed
2012-07-16 05:02:33 -07:00
PKEuS 5caab6ba10 Fixed crash on garbage code (#3870) 2012-07-06 09:03:33 -07:00
Ettl Martin 7401104f45 #2773 added missing testcase 2012-07-02 10:01:37 +02:00
Daniel Marjamäki 0042ee7bc8 Fixed #3660 (False positive memleak (allocation function uses non-local variable)) 2012-06-25 20:00:50 +02:00
Daniel Marjamäki abde1d0ec1 added comment in test case 2012-06-23 20:20:11 +02:00
Daniel Marjamäki 72d24ab4b4 Fixed #3904 (false positive memory leak with linked list) 2012-06-23 20:15:58 +02:00
Daniel Marjamäki a823d29da3 Fixed #3809 (false positive: memory leak) 2012-06-01 19:01:19 +02:00
Ettl Martin 1620c5b797 added todo testcase for ticket #3809 2012-05-29 21:44:39 +02:00
Daniel Marjamäki 2e41510e30 Fixed #3806 (Possible leak in public function. The pointer '' is not deallocated before it is allocated) 2012-05-29 21:13:34 +02:00
PKEuS 1a5fbd61d2 Splitted class TokenList from Tokenizer 2012-05-05 09:33:26 -07:00
PKEuS 04704ac5fa Refactorizations in checkmemoryleak.cpp:
- Use symbolDatabase more often to increase performance and accuracy.
- Replaced indendation counter
- Replaced custom stringify implementation

Benchmark results (sqlite checking):
4% complete, 7% on "Memory leaks (function variables)", 9% on "Memory leaks (address not taken)" and 82% on "Memory leaks (struct members)"
2012-05-03 10:43:47 +02:00
Ettl Martin 8494df74e6 #2540: added missing testcase. 2012-04-26 13:16:46 +02:00
PKEuS 4dcb2ef57b Refactorizations in test suite:
- Removed again one custom stringify implementation
- Avoided unnecessary std::string creation in testbufferoverrun.cpp
2012-04-16 20:02:52 +02:00
Daniel Marjamäki 8e3f1702fd Reverted 81318b3f to get rid of #3669 false positives 2012-04-10 13:58:59 +02:00
Pierre Schweitzer 9d002916f4 Fix line number displayed on leakNoVarr error 2012-03-20 22:28:56 +01:00
Pierre Schweitzer 544a1f714e Updated error message about not taking return value from function that returns allocated memory 2012-03-18 13:45:50 +01:00
Daniel Marjamäki 1e125dc017 Fixed #3671 (False positive: Resource leak: fd) 2012-03-18 11:54:09 +01:00
Daniel Marjamäki 29063098bf Fixed #3670 (false positive: Allocation with open never assigned) 2012-03-18 07:49:22 +01:00
Pierre Schweitzer 5dc4fcaa0a Add two tests for the new memory leak detection 2012-03-14 23:45:20 +01:00
Daniel Marjamäki 5ae7c4506f Fixed #3015 (xml-style error output when running testrunner on particular tests) 2012-01-06 09:09:46 +01:00
Reijo Tomperi 8cae17fda8 Update year to 2012 2012-01-01 01:05:37 +02:00
Daniel Marjamäki 6d98406d71 Fixed #3444 (False positive using putenv) 2011-12-29 07:35:27 +01:00
PKEuS 9b685ba3c3 Code cleanup 2011-12-09 21:00:57 +01:00
PKEuS 1bef8d1247 Tokenizer: Code cleanups 2011-12-08 17:42:26 +01:00
Daniel Marjamäki fb3115a199 Fixed #3267 (False positive: resource leak in vdr-xinelib) 2011-12-03 09:53:36 +01:00
Daniel Marjamäki d0247f3a8d Fixed #3268 (False positive: resource leak in vdr-xineliboutput) 2011-11-30 20:07:56 +01:00
Daniel Marjamäki dcd3f4fe3d Fixed #3267 (False positive (experimental): resource leak in vdr-xinelib) 2011-11-30 19:43:02 +01:00
Daniel Marjamäki 39af75abb4 Fixed #3303 (false positive: memory leak (reference count)) 2011-11-28 20:08:29 +01:00
Daniel Marjamäki 50c320ef27 memory leaks: Made leak checking inconclusive instead of experimental 2011-11-25 14:47:45 +01:00
Marek Zmysłowski 3ae96600b5 Fixed #3212 (Simplify the double pointer cast) 2011-11-25 07:23:54 +01:00
Daniel Marjamäki 690702a742 Memory leaks: Made CheckMemoryLeakInFunction experimental 2011-11-20 14:11:22 +01:00
Daniel Marjamäki 688e290332 Memory leaks: Fixed false positive for 'char *p = strcpy(malloc(10),str);' 2011-11-11 09:07:02 +01:00
Marek Zmysłowski fed875f4a4 Fix #70 (Locate memory leaks when alloc happens in function parameter)
http://sourceforge.net/apps/trac/cppcheck/ticket/70
2011-11-07 23:50:57 +02:00
Thomas Jarosch 91a5d95bc9 Use Token::simpleMatch() / Token::findsimplematch() where possible 2011-10-28 22:31:05 +02:00
seb777 1a6706005f Test to close Ticket #1879 2011-10-25 22:38:23 +02:00
Edoardo Prezioso 6f80c5ff64 Removed redundant test, which was related to the Tokenizer, not to the memory leak checker. 2011-10-16 21:19:18 +02:00
Jonathan Neuschäfer 4fb7865f49 fix typos using codespell
Codespell is available at http://git.profusion.mobi/cgit.cgi/lucas/codespell/.
2011-10-13 22:04:41 +02:00
Daniel Marjamäki 6f8e42a5af changed the astyle formatting flags 2011-10-13 20:53:06 +02:00
Marek Zmysłowski 07d8cd0a12 improved realloc checking '*p = realloc(*p,..'. Ticket: #1791 2011-10-11 22:07:14 +02:00
Edoardo Prezioso 1ff7410f4f Fixed #3075 (False positive => Improve tokenizer: remove redundant code after a 'return' state) 2011-09-13 07:55:47 +02:00
Daniel Marjamäki 84f190abf7 Fixed #3096 (false negative: memory leak not found when passing string to strtok) 2011-09-09 07:25:47 +02:00
Robert Reif acebc635b5 add support for deallocating memory with realloc 2011-08-30 23:42:11 -04:00
Daniel Marjamäki a1aa66f370 Fixed #3039 (False Positive: Memory Leak 'p = pop(p);') 2011-08-28 11:28:14 +02:00
Daniel Marjamäki 15e965b530 Fixed #3038 (False Positive - memory leak (struct member passed to subfunction)) 2011-08-26 19:26:21 +02:00
Daniel Marjamäki 6d9463139d Fixed #3038 (False Positive - memory leak) 2011-08-25 19:59:44 +02:00
Daniel Marjamäki 2f0fc9444f Fixed #3041 (false positive reported for error with id='deallocuse') 2011-08-23 23:18:47 +02:00
Daniel Marjamäki dd09b24208 Fixed #3024 (False positive: memory leak for 'rc.bitmap' when rc is added to linux kernel list) 2011-08-20 09:17:34 +02:00
Daniel Marjamäki 5f25f2c6e6 Fixed #3012 (False Pos Memory Leak with a Macro) 2011-08-16 20:39:17 +02:00
Daniel Marjamäki 2150995475 Fixed #2981 (False positive: struct member leak) 2011-08-08 19:58:49 +02:00
Kimmo Varis cfcfa3f000 Use "enabled" list for the style checking.
Settings-class currently enables style checking via dedicated
boolean attribute. All other CLI's enable-options are handled
through the enable-list. This commit moves style-check enabling
to use the enable-list.

Main advantage is the consistency how options are handled/stored
in the Settings class. Which also unifies using them for the other
code. You need to enable certain type of checks? Use the
addEnabled()-method. You want to check if certain type of checks
are enabled? Use the isEnabled()-method.
2011-08-07 10:28:52 +03:00
Robert Reif 222ed6d375 fix #2971 (Wrong warning generated) 2011-08-06 19:10:15 -04:00
Daniel Marjamäki 5fc2a55bac Fixed #2900 (found memory leak in kernel p54usb and a false positive reported) 2011-08-02 09:04:13 +02:00
Daniel Marjamäki 4e6800c474 Fixed #2921 (False positive: Memory leak with static pointer) 2011-07-24 16:08:29 +02:00
Daniel Marjamäki d34a778848 Fixed #2848 (False positive: Memory leak when assigning and freeing from another struct) 2011-07-21 13:33:20 +02:00
Robert Reif af1e51f648 fix some more false negatives for #2904 (Memory leak not detected when creating a new class instance) 2011-07-14 20:45:27 -04:00
Robert Reif 270b2b1772 fix #2904 (Memory leak not detected when creating a new class instance) 2011-07-14 19:15:59 -04:00
Reijo Tomperi 89fd5bacf9 Fix #2849, False positive: memory leak (using question mark operator)
http://sourceforge.net/apps/trac/cppcheck/ticket/2849
Simplify: *d = b ? b : a; into if-else
Simplify { ; { ; } } into { ; }
Removed one memleak test which should be redundant now as question marks
should not get into memleak check.
2011-06-30 22:04:26 +03:00
Daniel Marjamäki 6375e1d3dc Fixed #2849 (False positive: memory leak (using question mark operator)) 2011-06-30 17:31:22 +02:00
Daniel Marjamäki cacca00080 Fixed #2855 (False positive: resource leak when reusing fd) 2011-06-29 20:00:21 +02:00
Daniel Marjamäki 47a15b6486 Fixed #2830 (false positive: resource leak when using fdopen) 2011-06-20 18:42:13 +02:00
Daniel Marjamäki 1b4b4ee43e Fixed #2806 (False positive with g_strstrip()) 2011-05-29 17:44:10 +02:00
Daniel Marjamäki 52499ca8f8 Fixed #2790 (Incorrect allocation mismatch error) 2011-05-19 19:41:18 +02:00
Daniel Marjamäki 1c992fe25a Fixed #2783 (Improve check: struct member leaks when analysing c file) 2011-05-11 18:19:14 +02:00
Daniel Marjamäki a79e979ae4 Memory leaks: Fixed TODO test case. Ticket: #2733 2011-04-20 17:16:09 +02:00
Daniel Marjamäki 46afc54c10 astyle formatting 2011-04-20 06:41:26 +02:00