Commit Graph

195 Commits

Author SHA1 Message Date
Slava Semushin 8dcb846627 Fixed #614 (If you see this, there is a bug ###### Token::Match() - varid was 0)
http://sourceforge.net/apps/trac/cppcheck/ticket/614
2009-08-26 02:44:19 +07:00
Slava Semushin 311fb1a1f8 src/checkmemoryleak.{h,cpp}: minor improvements.
Corrections for commit 0d6b6e840d

No functional change.
2009-08-26 02:32:10 +07:00
Slava Semushin ff3d1db480 Replace "const unsigned int" to "unsigned int" in methods parameters.
No functional change.
2009-08-26 02:26:12 +07:00
Daniel Marjamäki 522f4c18c8 astyle formatting 2009-08-23 17:17:57 +02:00
Daniel Marjamäki 9da2ecf4f4 Refactoring the unit testing. Wrote special tests for CheckMemoryLeakInFunction::findleak 2009-08-23 15:48:25 +02:00
Benjamin Kramer 0d6b6e840d Improve performance by using bsearch(3) instead of a std::set
The function name list is already in memory so we can avoid copying it into a std::set
if we sort the list alphabetically. This way no binary search tree has to be allocated.

Before (best of 5 runs):
./testrunner > /dev/null  0,21s user 0,00s system 95% cpu 0,221 total
After (best of 5 runs):
./testrunner > /dev/null  0,20s user 0,00s system 95% cpu 0,210 total
2009-08-22 20:24:26 +02:00
Daniel Marjamäki 8b46172bcf Memory leaks: Use varid instead of varname 2009-08-19 19:42:07 +02:00
Daniel Marjamäki 85682ed429 Fixed #591 (False positive: Deallocating a deallocated pointer) 2009-08-18 20:49:08 +02:00
Daniel Marjamäki 2cdb0abb82 Refactoring: Use the Token::link instead of loop 2009-08-17 22:23:37 +02:00
Daniel Marjamäki 52856fcbeb ettlmartin: improved the MathLib::IsInt 2009-08-16 18:45:26 +02:00
Slava Semushin 522f783ada CheckMemoryLeak: try to speed up call_func().
Using std::set::find() instead of sequence of Match() calls.
2009-08-16 22:02:11 +07:00
Daniel Marjamäki ecdbcbce3d Fixed #566 (False positive when assigning the return value of realloc(NULL,..) to a pointer variable holding a freed memory address) 2009-08-10 22:04:28 +02:00
Daniel Marjamäki ce8c5b0236 Fixed #555 (False positive: [CuTest.c:25]: (error) Memory leak: len) 2009-08-05 21:18:16 +02:00
Daniel Marjamäki cb57bd6678 Listing error messages in XML format 2009-08-04 21:36:55 +02:00
Daniel Marjamäki 9e348ca739 Fixed #554 (resource leak false positive) 2009-08-04 21:34:14 +02:00
Reijo Tomperi 769119c725 Fix ticket #552 (False positive with --all when realloc is used with two variables.)
http://sourceforge.net/apps/trac/cppcheck/ticket/552
2009-08-02 23:30:43 +03:00
Reijo Tomperi 10f6678cf9 TODO test case realloc5 added and "Checkmemoryleak: simplifycode result for" debug info added. 2009-08-02 22:23:47 +03:00
Daniel Marjamäki b7ffcf53ba Fixed #511 (false positive, memory leak when using 'var = ({});') 2009-07-31 23:42:21 +02:00
Daniel Marjamäki 050b85c5eb memory leak for struct member: fixed false positive when the struct pointer is stored away 2009-07-29 11:38:20 +02:00
Slava Semushin 65d6bce165 Replace Match() to operator==() from std::string.
No functional change.
2009-07-28 00:13:44 +07:00
Slava Semushin 5ce151983e Replace simpleMatch() to operator==() from std::string.
No functional change.
2009-07-28 00:13:11 +07:00
Slava Semushin 8643936e0c Fixed ticket #500 (Tokenizer: simplify the "(p != NULL)" conditions)
Also teach simplifyIfNot() to handle variables like Foo::var.

https://sourceforge.net/apps/trac/cppcheck/ticket/500
2009-07-25 18:23:03 +07:00
Daniel Marjamäki 9136d8cf80 Tokenizer: simplify return statements - remove redundant parantheses 2009-07-24 21:55:35 +02:00
Daniel Marjamäki 6bb85703f6 memory leaks: fixed false positive for struct members - better handling of if/else 2009-07-24 09:05:40 +02:00
Daniel Marjamäki 565ac2fca6 Fixed #493 (Memory leak: False positive when using the exit(0)) 2009-07-23 16:30:30 +02:00
Daniel Marjamäki 3243933c90 Fixed #494 (False positives of checking leaks struct members)
Better handling of function calls
2009-07-22 08:30:51 +02:00
Daniel Marjamäki 6f646246ee dereferencing deallocated memory: it is ok to take the address to deallocated memory but it is not ok to dereference the address 2009-07-21 13:04:13 +02:00
Reijo Tomperi d2278b5ce0 Fix some of the issues from #478 (Warnings in Visual Studio build with -W4)
http://sourceforge.net/apps/trac/cppcheck/ticket/478
2009-07-20 23:24:23 +03:00
Daniel Marjamäki 74699cab66 memory leak for struct member: made the checking more sensitive. Skip bail-out execution paths were the member is properly deallocated 2009-07-20 14:39:24 +02:00
Daniel Marjamäki ddaea3244d memleak: implemented simple checking for leaking struct members 2009-07-19 16:51:31 +02:00
Slava Semushin 2ba0897ecb src/checkmemoryleak.cpp: added fchmod() function to white list. 2009-07-18 23:48:48 +07:00
Slava Semushin a0a526a205 Fixed ticket #464 (resource leak not detected when getc is used on the file handle)
http://sourceforge.net/apps/trac/cppcheck/ticket/464
2009-07-18 18:32:55 +07:00
Daniel Marjamäki 4f2520bef3 doxygen: made the todos visible in the doxygen output 2009-07-14 08:17:12 +02:00
Daniel Marjamäki 913789605f refactoring: Refactoring of the leak-checking classes 2009-07-13 15:07:26 +02:00
Daniel Marjamäki 7d35447d80 refactoring: renamed the severity "all" to "possible error" 2009-07-13 10:16:31 +02:00
Daniel Marjamäki 2a02041fd8 memleak: fixed todo test case 2009-07-07 15:22:37 +02:00
Daniel Marjamäki 9beb73824b Fixed #446 (memory leak false positive when variable is static) 2009-07-06 12:20:13 +02:00
Reijo Tomperi 8b0e481d46 Refactoring: Rename member functions to follow naming guidelines. 2009-07-05 23:16:43 +03:00
Daniel Marjamäki 61f4a29758 minor fix of test case 2009-06-23 20:40:27 +02:00
Daniel Marjamäki 7f8b40d135 calling unknown function -> use 2009-06-23 20:37:34 +02:00
Daniel Marjamäki 5c36d33943 astyle formatting 2009-06-21 21:03:58 +02:00
Slava Semushin 13e805f332 Fixed ticket #399 (Add detection for resource leaks after open() usage)
http://sourceforge.net/apps/trac/cppcheck/ticket/399
2009-06-21 22:01:43 +07:00
Daniel Marjamäki 8715ba1458 CheckMemoryLeakInFunction: More sensitive checking when the code calls an unknown function 2009-06-21 14:12:59 +02:00
Daniel Marjamäki f28dec1f5a detect memory leak when all is given when calling an unknown function 2009-06-21 13:48:39 +02:00
Daniel Marjamäki d1d9c9a9c9 CheckMemoryLeakInClass: Only show the memory leak message when --all is used 2009-06-20 14:17:56 +02:00
Daniel Marjamäki 453a5cdd47 Fixed ticket #411 (false positive: resource leak in while loop) 2009-06-20 13:58:30 +02:00
Daniel Marjamäki 5d0d21d668 Fixed a false positive (memory leak)
This false positive was first discovered in the VLC sourcecode. The TestMemoryLeakInFunction::simple11 test case is a simplified test code of that code.
2009-06-17 21:42:49 +02:00
Daniel Marjamäki ed98f1b367 Fixed #131 (Regression: leak reported by 1.27 is not reported by 1.29)
The leak will be reported as a definite bug again. Not just a possible bug.
cppcheck don't know if the execution path is possible, but it knows that if the execution path is taken the memory leak will be certain.
2009-06-16 19:05:05 +02:00
Daniel Marjamäki a81b6487bf Improved the "CheckMemoryLeak::functionReturnType" 2009-06-15 21:13:39 +02:00
Daniel Marjamäki 433ff048a4 Fixed #264 (Memory Leak: alloc by assigning to a return value)
The fix was inspired by the previous patch submitted by hoangtuansu
2009-06-15 17:44:59 +02:00
Slava Semushin 8c327f82b3 Fixed ticket #346 (adding a "const" token prevents detection of memory leak)
http://sourceforge.net/apps/trac/cppcheck/ticket/346
2009-06-15 00:32:34 +07:00
Slava Semushin 57f1a6d2b7 Replace tok->previous()->previous()->previous() call to tok->tokAt(-3).
Done by command:
git grep -l 'previous()->previous()->previous()' |
xargs sed -i 's|previous()->previous()->previous()|tokAt(-3)|'

No functional change.
2009-06-14 13:33:45 +07:00
Slava Semushin 4245047674 Replace tok->next()->next() call to tok->tokAt(2).
Done by command:
git grep -l 'next()->next()' | xargs sed -i 's|next()->next()|tokAt(2)|'

No functional change.
2009-06-14 13:33:45 +07:00
Slava Semushin ab0a1973e8 Replace tok->next()->next()->next() call to tok->tokAt(3).
Done by command:
git grep -l 'next()->next()->next(),' | xargs sed -i 's|next()->next()->next()|tokAt(3)|'

No functional change.
2009-06-14 13:33:44 +07:00
Slava Semushin b3841dda96 Replace tok->next()->next()->next()->next() call to tok->tokAt(4).
Done by command:
git grep -l 'next()->next()->next()->next(),' | xargs sed -i 's|next()->next()->next()->next()|tokAt(4)|'

No functional change.
2009-06-14 13:33:44 +07:00
Daniel Marjamäki 777790ebc7 Fixed ticket #367 (Deallocating a deallocated pointer false positive when va_list used)
The overall matching of functions when calls are made were improved.
2009-06-12 17:31:29 +02:00
Daniel Marjamäki 2c07c22d9e Refactoring: Split up the CheckMemoryLeak into CheckMemoryLeakInFunction and CheckMemoryLeakInClass 2009-06-08 20:20:43 +02:00
Daniel Marjamäki 15dbf9c085 Refactoring: Renaming the CheckMemoryLeakClass to CheckMemoryLeak. Deleted testmemleakmp 2009-06-08 18:51:17 +02:00
Reijo Tomperi 9bac4aca75 Fix ticket #371 (Resource leak when exit() and if() uses together)
http://apps.sourceforge.net/trac/cppcheck/ticket/371
2009-06-07 09:55:20 +03:00
Daniel Marjamäki a8c5526c84 Fix #368 (Leak detected when allocated memory assigned to member of structure which returned from function)
The return value of strcpy wasn't handled very well
2009-06-06 20:55:16 +02:00
Daniel Marjamäki d0f3dccc6d Fixed #354 (false positive: memory leak) 2009-06-05 08:56:46 +02:00
Slava Semushin 21e0639443 Fixed ticket #360 (Teach about new(std::nothrow) form)
http://apps.sourceforge.net/trac/cppcheck/ticket/360
2009-06-05 11:03:48 +07:00
Reijo Tomperi 1bb7b01a06 Fix ticket #352 (Memory leaks: Missed memory leak when "--all" is not given)
http://apps.sourceforge.net/trac/cppcheck/ticket/352
Detect memory leaks without --all when there is "alloc ; assign callfunc ;
2009-06-03 23:20:33 +03:00
Slava Semushin 37a485f4f0 Fixed ticket #349 (Add detection for resource leaks after tmpfile() usage)
https://apps.sourceforge.net/trac/cppcheck/ticket/349
2009-06-01 17:40:24 +07:00
Daniel Marjamäki bf98ff85e5 Memory leaks: calling function that deallocates the memory and allocates new memory
https://apps.sourceforge.net/trac/cppcheck/ticket/336
2009-05-30 20:30:44 +02:00
Reijo Tomperi 58eda6e978 Fix ticket #325 (Replace developer names in source files with AUTHORS file)
http://apps.sourceforge.net/trac/cppcheck/ticket/325
2009-05-30 08:48:12 +03:00
Slava Semushin 9ae9ffa9be src/checkmemoryleak.cpp(GetAllocationType): simplify condition a bit.
Replace two Token::simpleMatch() calls to one Token::Match().

Correction for my previous (2654a4aa54)
commit.

No functional change.
2009-05-24 03:46:50 +07:00
Slava Semushin 2654a4aa54 Added support to search resource leaks after opendir()/fdopendir() usage. 2009-05-24 02:53:02 +07:00
Slava Semushin 1e2545439e src/checkmemoryleak.cpp(GetDeallocationType): removed brackets.
No functional change.
2009-05-24 00:26:34 +07:00
Slava Semushin bfd49e21e7 Added 17 functions which work with FILE structure to white list.
Inspired by previous commit.
2009-05-23 18:01:18 +07:00
Slava Semushin b5c7316666 Fixed ticket #327 (File descriptor leak not detected when feof() used)
Thanks to aggro80@ for help.

http://apps.sourceforge.net/trac/cppcheck/ticket/327
2009-05-23 17:20:26 +07:00
Slava Semushin 0f20ce738d Replaced two Token::simpleMatch() calls to one Token::Match().
Suggested by hyd_danmar in ticket
http://apps.sourceforge.net/trac/cppcheck/ticket/323

No functional change.
2009-05-22 22:03:42 +07:00
Slava Semushin a2a6eebb01 Fixed ticket #324 (Teach about fcloseall() function)
http://apps.sourceforge.net/trac/cppcheck/ticket/324
2009-05-22 21:47:40 +07:00
Reijo Tomperi e6017ad54b Fix #299 (Memory leak not detected when parameters contain ::)
http://apps.sourceforge.net/trac/cppcheck/ticket/299
2009-05-21 22:51:19 +03:00
Daniel Marjamäki f182365bd2 Applied patch 0001-Use-Token-simpleMatch-instead-of-Token-Match-w
Author: php-coder

Ticket: http://apps.sourceforge.net/trac/cppcheck/ticket/323
2009-05-21 17:55:52 +02:00
Daniel Marjamäki 47e10b75e3 Applied patch 0003-GetAllocationType-mark-some-members-as-static-and-a.patch
Author: php-coder

Ticket: http://apps.sourceforge.net/trac/cppcheck/ticket/321
2009-05-21 12:26:44 +02:00
Daniel Marjamäki eafb1f823c Applied patch 0002-CheckMemoryLeak-renamed-enum-members.patch
Author: php-coder
2009-05-21 12:16:42 +02:00
Reijo Tomperi 9c60391375 Apply patch #320 from php-coderrr ([PATCH] Determine memory leaks after strndup() usage)
http://apps.sourceforge.net/trac/cppcheck/ticket/320
2009-05-19 23:29:10 +03:00
Daniel Marjamäki daea0547fa memory leaks: Handling exit (#297) 2009-05-10 08:01:38 +02:00
Daniel Marjamäki a32114b15c memleak: removed false positives for pclose (#286) 2009-05-06 21:31:31 +02:00
Reijo Tomperi cb209bbd41 Fix #279 (Refactoring: replace and remove Token::aaaa , Token::aaaa0 and Token::aaaa1)
http://apps.sourceforge.net/trac/cppcheck/ticket/279
2009-05-03 21:10:59 +03:00
Daniel Marjamäki e26c999020 Refactoring: Using MathLib for converting string to number
commit beacd5793f9e9987432a20ac39a76ae6c2c8babd
Author: Daniel Marjamäki <hyd_danmar@users.sourceforge.net>
Date:   Sat May 2 10:44:18 2009 +0200

    memleak: using mathlib

commit 4d28172a5d88cc2cbe5ed94a4e4fdbd0dd4bb5e1
Author: Daniel Marjamäki <hyd_danmar@users.sourceforge.net>
Date:   Sat May 2 10:35:06 2009 +0200

    tokenizer: using the MathLib for converting string to number

commit 4e4b95b3554c9c6d121efeb39741204b1621b1a3
Author: Daniel Marjamäki <hyd_danmar@users.sourceforge.net>
Date:   Sat May 2 10:28:39 2009 +0200

    CheckOther: Using mathlib
2009-05-02 10:45:15 +02:00
Reijo Tomperi a46de47158 Fix ticket #196 (False positive: Resource leak)
http://apps.sourceforge.net/trac/cppcheck/ticket/196
2009-05-01 14:39:57 +03:00
Reijo Tomperi 34540fee04 Fix partially ticket #196 False positive: Resource leak
And add few test cases related to it. Move one failing test behind TODO
http://apps.sourceforge.net/trac/cppcheck/ticket/196
2009-05-01 12:28:33 +03:00
Daniel Marjamäki bb154da394 memory leaks: handling std::auto_ptr (#266) 2009-04-28 20:01:35 +02:00
Daniel Marjamäki 06776c6ac7 Fixed the testcase TestMemleak::realloc3 2009-03-23 18:34:59 +01:00
Daniel Marjamäki 6fc66d3e2c refactoring error messages 2009-03-21 21:33:27 +01:00
Daniel Marjamäki 468ed653e2 refactoring error messages 2009-03-21 17:58:13 +01:00
Daniel Marjamäki 9f1c3cc535 refactoring the rest of the classes 2009-03-20 18:16:21 +01:00
Reijo Tomperi c385b3e045 Improve creation of link() for Token class. Tokenizer::simplifyTokenList() should now return
code where Token::link() actually works.
2009-03-15 01:39:45 +02:00
Daniel Marjamäki 75d0e8687b Memory leak: handle allocation in deallocation list 2009-03-14 20:19:36 +01:00
Daniel Marjamäki 02df14ec37 Memory leaks: Refactoring to use Tokenizer::FindClassFunction. Enabled test case, the memory leak is now detected 2009-03-14 18:21:37 +01:00
Daniel Marjamäki c7c13ce3c1 Fixed ticket 134 (memory leak not detected) caused by wrong checking if code is inside class function or not 2009-03-10 20:44:24 +01:00
Daniel Marjamäki d7cd09cb6e added internal support for handling list of classes that are automaticly deallocated 2009-03-06 07:22:07 +01:00
Reijo Tomperi 832275bc37 Fix #132 (False positive returning memcpy()) 2009-03-03 20:39:17 +00:00
Daniel Marjamäki 87b0314e72 memory leak: fixed issue with reporting wrong location 2009-03-01 20:34:04 +00:00
Reijo Tomperi fc8f47145a Copyrights updated 2009-03-01 19:52:33 +00:00
Daniel Marjamäki 35583293ec memory leak: Fixed a false positive when all is given 2009-02-25 19:20:23 +00:00
Daniel Marjamäki d15aea1b0c memory leak: fixed false positive when using 'return strcpy' 2009-02-24 06:23:21 +00:00
Daniel Marjamäki 44a5cecd99 memory leaks: improved handling of --vcl 2009-02-23 19:32:54 +00:00