Oliver Stöneberg
9028b4a81d
do not access static methods through instance ( #2189 )
2019-09-20 21:54:30 +02:00
Rikard Falkeborn
007b5d3e8d
Fix #9343 (memleak FP when return with cast) ( #2162 )
...
This was most likely introduced when the checks were changed to run on
the full tokenlist instead of the simplified one.
Take care to warn about cases where casts destroy the pointer, such as
uint8_t f() {
void* x = malloc(1);
return (uint8_t)x;
}
2019-09-20 15:09:27 +02:00
Daniel Marjamäki
9fa1a5a540
astyle formatting
...
[ci skip]
2019-08-07 08:05:46 +02:00
Ken-Patrick
cb0b057595
8706 ( #2066 )
...
* 8706
* Add test case for #8706
2019-08-07 08:04:10 +02:00
Rikard Falkeborn
f95d193e22
Fix #8282 (memleak FP when returning std::pair) ( #2039 )
2019-07-26 07:03:58 +02:00
Rikard Falkeborn
abea580b78
Fix FP memory leak with unknown function call in condition ( #2012 )
...
* Fix FP memory leak with unknown function call in condition
This was introduced in 8513fb81d2
when
fixing memory leaks for global variables allocated in condition. The
refactored code had an inconsistency where c and c++ code behaved
slightly differently when `var` is NULL. This seemed to not have an
impact as the code was written prior to 8513fb81d2
,
but when the same code was used for conditions, FPs were introduced.
The introduced FPs were memleak warnings when there should have been an
information message about missing configurations for code like
void f() {
char *p = malloc(10);
if (set_data(p)) {}
}
Fix this by always returning true if varTok->Variable() is NULL for
both c and c++ code.
* Improve function name
2019-07-18 15:23:19 +02:00
Daniel Marjamäki
5800692fa1
Move and refactor the CheckMemoryLeak::isclass
2019-07-17 08:59:09 +02:00
Rikard Falkeborn
8513fb81d2
Fix #9206 (FP with global variable allocated in condition) ( #2007 )
2019-07-17 07:43:07 +02:00
IOBYTE
c2ccfd5f8b
Increase Windows stack size to 8M ( #1998 )
...
* Increase Windows stack size to 8M
* try to add stack size cmake
2019-07-15 12:39:58 +02:00
IOBYTE
526a86dc60
Fix recursiveCount in CheckLeakAutoVar to really be recursive count. ( #1988 )
2019-07-13 07:40:24 +02:00
Daniel Marjamäki
ae933c20c7
Fixed #1765 (Improve check: delete not handled well when there are extra parentheses)
2019-07-12 18:25:20 +02:00
IOBYTE
74e3114a64
Fix #9097 (Crash on thousands of "else ifs"s in gcc-avr package) ( #1982 )
...
* Fix #9097 (Crash on thousands of "else ifs"s in gcc-avr package)
* increase recursion count maximum to 512 because cppcheck was hitting the 256 limit
* 512 was too much for windows
2019-07-12 07:56:05 +02:00
Rikard Falkeborn
a1a14b8465
Fix FP with cast pointer to free() ( #1961 )
...
This fixes false positives when the pointer passed to free() (or similar
deallocation functions) is cast using a c-style cast.
2019-07-10 09:13:59 +02:00
Rikard Falkeborn
839fcddd8a
Fix #6115 (Add support to realloc to cfg files) ( #1953 )
...
* Allow to configure realloc like functions
* memleakonrealloc: Bring back tests.
The old memleak checker was removed, and the tests for it was removed in
commit 9765a2dfab
. This also removed the
tests for memleakOnRealloc. Bring back those tests, somewhat modified
since the checker no longer checks for memory leaks.
* Add realloc to mem leak check
* Add tests of realloc buffer size
* Configure realloc functions
* Add test of freopen
* Allow to configure which element is realloc argument
* Fix wrong close in test
cppcheck now warns for this
* Update manual
* Update docs
* Rename alloc/dalloc/realloc functions
Naming the member function realloc caused problems on appveyor. Rename
the alloc and dealloc functions as well for consistency.
* Change comparisson order
* Remove variable and use function call directly
* Create temporary variable to simplify
* Throw mismatchError on mismatching allocation/reallocation
* Refactor to separate function
* Fix potential nullptr dereference
As pointed out by cppcheck.
2019-07-05 12:44:52 +02:00
Rikard Falkeborn
60a213e6a5
Fix #9047 (c-style casts before malloc) ( #1930 )
...
* Fix #9047 (c-style casts before malloc)
Note that there are still no warnings for c++-style casts
* Fix memleak check with casts of assignments in if-statements
* Fix possible null pointer dereference
As pointed out by cppcheck.
* Add check of astOperand2 when removing casts
This is similar to how it is done in other checks.
2019-07-03 08:39:44 +02:00
Daniel Marjamäki
7a3302b3e3
CheckLeakAutoVar: Fixed FP seen in daca@home
2019-06-02 15:25:54 +02:00
Daniel Marjamäki
4da50942b0
Fixed #8120 (False positive: Memory pointed to by 'p' is freed twice)
2019-05-30 16:22:41 +02:00
Rikard Falkeborn
ada881ccdf
Fix #9130 (FP memory leak with NULL pointer cast) ( #1839 )
2019-05-18 06:22:25 +02:00
Daniel Marjamäki
da46bff1b3
CheckLeakAutoVar: Use Library::isSmartPointer()
2019-04-24 15:35:47 +02:00
Daniel Marjamäki
3dc34f1515
Disable all simplified checks
2019-03-16 09:17:50 +01:00
Daniel Marjamäki
bd7790fd8c
Update copyright year
2019-02-09 07:24:06 +01:00
Daniel Marjamäki
54cebfaf94
Fixed #8392 (false positive: "Memory leak" with malloc in if)
2019-01-27 10:27:44 +01:00
Daniel Marjamäki
8dd641b8be
Use OVERRIDE in test
2019-01-12 15:45:25 +01:00
Daniel Marjamäki
75e367c48b
Fixed #8340 (incorrect memleak errors)
2019-01-09 19:50:41 +01:00
Daniel Marjamäki
0f9ce5edd5
Fixed #8365 (False positive on memory leak when assigned inside if statement)
2019-01-08 20:54:39 +01:00
Kamil Dudka
d206047b84
Fixed #8794 - Memory leak false positive triggered by !(x != NULL) ( #1450 )
2018-10-26 06:21:45 +02:00
Daniel Marjamäki
45379a3aa6
Updated copyright year for modified files
...
[ci skip]
2018-06-10 22:07:21 +02:00
umanamente
a3b02d6ece
Fixed #8262 : false positive memleak (`shared_ptr` in function argument) ( #1249 )
...
* Fixed #8262 .
checkleakautovar.cpp:
* added `isFunctionCall` (supports template functions)
* smart pointer check in `functionCall`
* updated test case
* Renamed "bracket" to "parenthesis"
* (#8262 ) Fixed broken test
* (#8262 ) Code review comments
* (#8262 ) Renamed `tokOpeningBr` to `tokOpeningPar`
2018-05-22 09:08:23 +02:00
Paul Fultz II
406aa6cf1c
Improve support of using a lambda as a deleter ( #1246 )
...
* Improve support of using a lambda as a deleter
* Use simple match
2018-05-21 08:22:18 +02:00
IOBYTE
ce50df8047
Fix override warnings. ( #1234 )
2018-05-15 16:37:40 +02:00
Daniel Marjamäki
66599b4ade
astyle formatting
...
[ci skip]
2018-05-14 22:48:37 +02:00
umanamente
d2d1bf900b
( #8262 ) Added TODO test for "False positive: memory leak with shared_ptr stored in container" ( #1228 )
2018-05-14 13:08:33 +02:00
Paul Fultz II
067d82f0ea
Check for smart pointer release ( #1206 )
2018-05-05 18:06:49 +02:00
Daniel Marjamäki
e1db4c0e2c
astyle formatting
...
[ci skip]
2018-04-21 13:28:31 +02:00
Paul Fultz II
bad66594d6
Fix double free regression with smart pointers ( #1184 )
2018-04-21 11:24:19 +02:00
Daniel Marjamäki
a4f8c44432
astyle formatting
...
[ci skip]
2018-04-16 12:55:37 +02:00
Paul Fultz II
2a657cfd08
Check for double frees when using smart pointers ( #1172 )
...
* Check for double frees when using smart pointers
* Some updates from feedback
* Add test for mismatch allocation
* Constants
* Check smart pointer deleter
* Switch order
* Use next
* Add owned state
* Fix handling of leaks
* Use ast for checking addressof operator
* Remove stray character
* Add a test for mismatch allocator
* Add another test for deallocating with custom function
2018-04-16 11:11:13 +02:00
Daniel Marjamäki
c4caee6b18
Updated copyright year
2018-01-14 15:37:52 +01:00
Björge Dijkstra
94031ef11d
Fix for conditional memory allocation inside if-condition ( #986 )
...
* Add test cases for allocation inside if-condition
* Fix missed memory leak and false positive double free for allocation inside if-condition
2017-10-26 19:11:00 +02:00
Daniel Marjamäki
7161daefbd
Fixed #8040 (False positive resourceLeak - handle assigned to class instead of scalar)
2017-07-08 22:28:31 +02:00
Daniel Marjamäki
6b48781fdc
Fixed #7105 (False positive resourceLeak - socket handle wiped after close)
2017-07-07 21:51:48 +02:00
Daniel Marjamäki
f847631cdb
Fixed #5273 (FP memleak: Unknown if() condition should make error inconclusive)
2017-06-30 23:05:09 +02:00
Ayaz Salikhov
28aa939d69
iwyu - include what you use
2017-05-27 04:33:47 +02:00
Daniel Marjamäki
65297ce285
Fixed #7191 (false positive memleak on in-place new)
2017-05-04 19:39:57 +02:00
Daniel Marjamäki
140e086206
Fixed #7738 (False positive deallocret - delete and return NULL pointer)
2017-04-24 22:05:16 +02:00
Daniel Marjamäki
50da7d4919
Tokenizer: Write syntax error if there is C++ code in C file.
2017-04-06 08:50:35 +02:00
Daniel Marjamäki
b5f2fd3c55
Fixed #7738 (False positive deallocret - delete and return NULL pointer)
2017-03-03 18:36:06 +01:00
Daniel Marjamäki
99544069d1
CheckLeakAutoVar: better handling of noreturn functions. Partial fix for #7918 .
2017-02-25 11:36:48 +01:00
Simon Martin
f43431408b
Ticket #7685 : Properly handle function calls as argument to a dealloc function. ( #853 )
...
Add an optional extended description…
2016-12-29 13:17:46 +01:00
Daniel Marjamäki
74fa69fe5e
Fixed #7821 (syntax error, first token is &)
2016-11-20 17:59:50 +01:00
PKEuS
54959d1932
CheckLeakAutoVar: Distinguish between new and new[] ( #888 )
2016-10-09 10:28:19 +02:00
Daniel Marjamäki
4b903a838f
Fixed #5522 (CheckLeakAutoVar: Don't treat 'x==p' as dereference of p)
2016-05-26 19:22:38 +02:00
Daniel Marjamäki
38741868b5
Fixed #3989 (false positive: memory leak (inline function))
2016-05-26 17:42:27 +02:00
PKEuS
64d2fd2f57
Added new attribute "arg" to <alloc> and <dealloc> to specify the argument that is allocated/deallocated.
...
This fixes several issues with allocation functions in windows.cfg, such as HeapAlloc() and VirtualAllocEx() (#7503 )
2016-05-22 17:19:14 +02:00
Daniel Marjamäki
c23c1f245c
Fixed #6989 (incorrect memleak error)
2016-05-21 14:03:28 +02:00
Daniel Marjamäki
2668cee3cf
Fixed #6397 (FP deallocuse - conditional deallocation and conditional return)
2016-05-15 20:27:44 +02:00
Kamil Dudka
efe98883ab
checkleakautovar: do not miss 'throw' followed by ::
2016-05-13 21:37:49 +02:00
PKEuS
f23668dfcc
Fixed false positive doubleFree ( #7401 )
2016-05-04 12:14:42 +02:00
Lauri Nurmi
996c9244d8
Update copyright year to 2007-2016.
2016-01-01 15:34:45 +02:00
Daniel Marjamäki
0f9d90d2be
Changed Copyrights. Removed my name.
2015-11-18 20:04:50 +01:00
PKEuS
3a5cef8a7e
Refactorization: Improved usage of Settings instances in test suite
2015-10-07 18:40:03 +02:00
PKEuS
93dbfb72d1
Improved REGISTER_TEST() macro to support several occurrences within a single file
2015-10-07 14:30:01 +02:00
Daniel Marjamäki
501ab0b6da
CheckLeakAutoVar: updated handling of unknown types in C++
2015-08-11 12:41:42 +02:00
Daniel Marjamäki
e5151a13ab
Fixed #6867 (False positive memleak)
2015-07-25 11:37:03 +02:00
Simon Martin
fa94f2e0f4
Ticket #6648 : Properly handle variables that have been deallocated and whose _address_ is taken after in CheckLeakAutoVar.
2015-07-19 17:37:50 +02:00
amai2012
4a47b8b3ae
Refactoring: Better distinguish between C and C++ in a few checks.
2015-06-28 16:49:16 +02:00
Alexander Mai
70ba6c4340
#6767 False positive: memory leak when variable name is 'new'. Fix handling of new in C code. Move some tests for TokenList to new testtokenlist.cpp
2015-06-14 15:49:49 +02:00
Alexander Mai
7416d6add9
Another fix for handling of final/override specifiers in Tokenizer::simplifyKeyword() including a testcase. Ran astyle
2015-05-23 20:51:15 +02:00
Pierre Schweitzer
5a68e352df
Add various tests targeting Windows platform to show the current troubles cppcheck has to distinguish two different source of allocation used together.
2015-05-19 21:23:09 +02:00
PKEuS
bc5132e0ac
Refactorization: Moved declaration of errout, ... to testsuite.h, uniformized style
2015-03-11 22:54:43 +01:00
Daniel Marjamäki
c2b85d1032
Fixed testrunner
2015-02-03 18:35:52 +01:00
PKEuS
80feb8697d
Fixed false positives #6473 and #6469
2015-01-29 21:26:06 +01:00
PKEuS
71379616e7
Fixed false positive #6467
2015-01-29 10:18:21 +01:00
PKEuS
9ada111045
Fixed false positive #6466
2015-01-29 09:50:48 +01:00
PKEuS
0488f45a5f
Removed standalone check CheckOther::checkDoubleFree(), integrated (most of) the functionality into CheckLeakAutoVar. Added support for new/delete to checkLeakAutoVar.
2015-01-28 17:38:43 +01:00
PKEuS
bdae9064ea
Support throw in checkleakautovar.cpp
2015-01-22 11:12:26 +01:00
Daniel Marjamäki
ff11ba9847
Updated copyright year to 2015
2015-01-03 12:14:58 +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
24ecaf8b0a
leakautovar: handling of unknown/non-pod types in c++
2014-10-14 16:40:30 +02:00
PKEuS
ccb5384645
Fixed false positive memoryLeak #6013
2014-09-30 13:02:02 +02:00
Jonathan Thackray
2b3ef83f26
Fixed #5747 (When socket() returns -1 on error, this shouldn't be marked as a resource leak)
2014-09-17 18:37:41 +02:00
Daniel Marjamäki
1ae6531c4c
Fixed #5923 (false positive: (error) Resource leak: fp (static file pointer))
2014-06-23 16:05:28 +02:00
Daniel Marjamäki
42b85088c5
Double free: Improved handling of noreturn functions. Partial revert of previous fix.
2014-05-04 13:11:21 +02:00
Daniel Marjamäki
636a15ac55
Doublefree: Fixed FP when exit() is called
2014-05-04 12:02:55 +02:00
Daniel Marjamäki
2d645f57b9
Fixed #5576 (false positive: (POSIX) (error) Resource leak: sockfd)
2014-04-18 18:18:47 +02:00
Daniel Marjamäki
fd3a8a2a18
Update copyright
2014-02-15 07:45:39 +01:00
PKEuS
4f0121ee2f
Splitted simplification out of tokenize()
2013-12-30 17:45:28 +01:00
PKEuS
a9a5dc0354
Updated to AStyle 2.03, require this version
2013-08-07 16:27:37 +02:00
Daniel Marjamäki
36ef34a2cf
astyle formatting
2013-07-28 11:53:49 +02:00
Simon Martin
470a9a6c71
Take into account break and continue statements in CheckLeakAutoVar.
2013-07-28 10:26:46 +02:00
Daniel Marjamäki
0c5e39a813
Library: Added configuration file std.cfg that clients should load.
2013-07-20 17:12:56 +02:00
Daniel Marjamäki
7eb1f36200
astyle formatting
2013-07-19 09:28:45 +02:00
Daniel Marjamäki
6fe1b92a47
Improved --check-library messages
2013-07-16 18:50:25 +02:00
Daniel Marjamäki
7d47fd65a2
Renamed --environment to --library. Added --check-library. Renamed Environment to Library
2013-07-08 18:26:18 +02:00
Daniel Marjamäki
d96fb577cd
CLI: Added --environment flag
2013-07-02 07:18:19 +02:00
Ettl Martin
1b9c1c03fa
unittests: removed not needed '\n' at the end of testcases.
2013-03-20 15:36:16 +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
PKEuS
735069e3a7
Fixed unit tests
2012-12-26 12:50:59 +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