Rikard Falkeborn
8cd1d5a47d
Use library for memleak checks ( #2002 )
...
* Use library for memleak checks
Change memleakOnRealloc and leakReturnValNotUsed to use library
configuration instead of hardcoding "realloc".
In order to do so, some care needs to be taken when matching for a
reallocation function, since it can no longer be assumed that the input
to be allocated is the first argument of the function. This complicates
getReallocationType() and checkReallocUsage() but is necessary in order
to handle for example freopen() properly.
Also, refactor memleakOnRealloc check to reduce duplicated code when
checking "a" and "*a". When doing so, extending the check to look for
arbitrary number of "*" can be done for free (just change an if
statement to a while statement). Most likely, this is an unusual case in
real world code.
* Remove redundant whitespace in Token::Match()
* Run on simplified checks
* Fix cppcheck warning
2019-07-22 10:37:36 +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
Scott Furry
a195477470
Correct Zero/Null as pointer constant ( #1938 )
...
Building with enhanced clang warnings indicated a large number of
instances with the warning:
`warning: zero as null pointer constant`
Recommended practice in C++11 is to use `nullptr` as value for
a NULL or empty pointer value. All instances where this warning
was encountered were corrected in this commit.
Where warning was encountered in dependency code (i.e. external library)
no chnages were made. Patching will be offered upstream.
2019-06-30 21:39:22 +02:00
Daniel Marjamäki
80d7df01cd
Fixed #8848 (False positive memory leak if locally defined type returns a new pointer)
2019-04-22 17:37:41 +02:00
Daniel Marjamäki
773d19b2d6
Fix compiler errors. After removing the -std=posix.
2019-04-12 10:41:53 +02:00
Daniel Marjamäki
bd7790fd8c
Update copyright year
2019-02-09 07:24:06 +01:00
Daniel Marjamäki
a4406aca32
Fixed #7845 (Leak reported when ignoring return value of 'new', even if pointer saved by constructor)
2019-02-03 12:15:05 +01:00
Daniel Marjamäki
21f7274533
Remove TestMemleakGlib and TestMemleakWindows
...
[ci skip]
2019-01-12 19:09:55 +01:00
Daniel Marjamäki
9765a2dfab
Remove unused test class. The old memleaks checker will not be used anymore.
2019-01-12 18:45:42 +01:00
Daniel Marjamäki
8dd641b8be
Use OVERRIDE in test
2019-01-12 15:45:25 +01:00
Daniel Marjamäki
35e56942d1
Fixed #8116 ([False positive] Invalid memory leak detection when using reference.)
2019-01-09 20:38:32 +01:00
Daniel Marjamäki
643ddd4caa
Code cleanup
2018-12-17 18:54:32 +01:00
Daniel Marjamäki
3b328f9187
CheckMemoryLeak: Cleanup the old memory leaks check
2018-12-17 18:12:50 +01:00
Daniel Marjamäki
3d629944da
Fixed #8100 (False positive when method/function defines lambda with pointer return value)
2018-11-12 11:28:38 +01:00
rikardfalkeborn
b3fef7957a
Fix FP with fclose after comma ( #7525 ) ( #1407 )
2018-10-01 11:58:27 +02:00
orbitcowboy
2f032d8fa7
Improved const correctness of local variables. ( #1396 )
...
* Improved const correctness of local variables.
* Running astyle [ci-skip].
* Removed duplicate 'const'-keyword.
2018-09-24 15:08:16 +02:00
Daniel Marjamäki
d8997bb43f
Fix testrunner
2018-08-05 14:01:24 +02:00
IOBYTE
ce50df8047
Fix override warnings. ( #1234 )
2018-05-15 16:37:40 +02:00
Daniel Marjamäki
f336c2efe7
Refactoring; Renamed Scope::classStart and Scope::classEnd
2018-04-27 22:36:30 +02:00
PKEuS
bbfcccf078
Refactorization: Replace several push_back-sequences by initializer lists
2018-04-09 09:41:24 +02:00
Paul Fultz II
54de7b48c9
Fix false positive when constructing with curly brace ( #1148 )
2018-04-05 06:47:59 +02:00
Daniel Marjamäki
c4caee6b18
Updated copyright year
2018-01-14 15:37:52 +01:00
PKEuS
b684e1f202
Updated AStyle to version 3.0.1
2018-01-08 20:20:33 +01:00
Martin Ettl
53fbfc9fdb
test: Various micro optimizations: Replaced std::string() with std::string(). Use std::string::clear() instead of s = and prefer std::string::empty() instead of (s == ) for checking a string is empty.
2018-01-05 22:03:49 +01:00
Ayaz Salikhov
28aa939d69
iwyu - include what you use
2017-05-27 04:33:47 +02:00
Daniel Marjamäki
040d2f0012
Use simplecpp lexer in test cases
2017-05-18 21:52:31 +02:00
Robert Reif
3dba1b1739
Tests for git pull request #882 .
2017-03-25 15:46:25 -04:00
Daniel Marjamäki
55d7ab65b9
Fixed #7918 (::exit() not recognized as noreturn)
2017-02-25 12:12:39 +01:00
Simon Martin
5262ed018e
Ticket #7440 : Function calls should not abort pointer alias analysis for local variables.
2017-01-27 22:56:28 +01:00
amai2012
722fac391d
Merge pull request #858 from simartin/ticket_7820
...
Ticket #7820 : Properly report leaks with conditional deallocations followed by a return.
2017-01-18 09:31:49 +01:00
Simon Martin
9e76b21d7f
Ticket #7820 : Properly report leaks with conditional deallocations followed by a return.
2017-01-17 23:02:39 +01:00
Simon Martin
ae939b1385
Teach CheckMemoryLeak about "alloc ; loop alloc ;" kinds of patterns. ( #861 )
...
Add an optional extended description…
2017-01-15 22:16:23 +01:00
Simon Martin
c82d8a0d06
Ticket #7745 : Simplify "alloc ; dealloc ;" blocks that we don't have any value for CheckMemoryLeak's analysis. ( #860 )
...
Add an optional extended description…
2017-01-15 22:14:37 +01:00
Robert Reif
4123b457d7
Fixed #7441 (SymbolDatabase: No scope when function return type not specified)
2017-01-06 11:53:17 +01:00
Daniel Marjamäki
85ae3adeb2
Fixed #5144 (FP old memleak - tree structure)
2016-12-27 08:12:37 +01:00
Simon Martin
f816fb811e
Ticket #7680 : Properly handle ::delete during memory leak checks.
2016-09-10 14:55:50 +02:00
PKEuS
5c92c231b8
windows.cfg: SendMessage must not be <leak-ignore/>
2016-07-26 11:57:46 +02:00
PKEuS
3916cd628e
windows.cfg: Fixed configuration of _tfopen_s/_wfopen_s (
2016-06-02 09:41:01 +02:00
Daniel Marjamäki
38741868b5
Fixed #3989 (false positive: memory leak (inline function))
2016-05-26 17:42:27 +02:00
Daniel Marjamäki
5a1bea2a09
Fixed #7244 (False memory leak when POD is allocated with value initialization and pushed onto container)
2016-05-14 14:56:51 +02:00
Alexander Mai
468a130447
Fix compiler warnings introduced by refactoring
2016-02-02 09:18:58 +01:00
PKEuS
4d01af3fe1
Fixed false positive in CheckMemoryLeakStructMember when returning a member that has been allocated ( #7302 ).
2016-01-31 10:10:48 +01:00
Daniel Marjamäki
0fb9ab7b4a
Refactoring CheckMemoryLeakNoVar::checkForUnusedReturnValue(). use continue
2016-01-25 10:33:11 +01:00
Daniel Marjamäki
642cc57428
CheckMemoryLeak: Fix FP when overloaded new is used
2016-01-20 10:34:03 +01:00
Lauri Nurmi
996c9244d8
Update copyright year to 2007-2016.
2016-01-01 15:34:45 +02:00
Alexander Mai
86c9387987
#7182 crash: CheckMemoryLeak::functionReturnType()
2015-12-05 18:43:29 +01:00
PKEuS
3b4160600d
Fixed crash in CheckMemoryLeak::functionReturnType() for unary operator:: ( #7172 )
2015-11-27 11:18:40 +01:00
PKEuS
0ba3d25917
CheckMemoryLeak: Correctly detect new char[...]() as array allocation ( #7164 )
2015-11-27 11:04:18 +01:00
PKEuS
c5b21d12cf
Removed lots of redundant tests from testmemleak.cpp, added some missing types to gtk.cfg
2015-11-19 18:51:32 +01:00
PKEuS
2e7c5d37df
Refactorizations in checkmemoryleak.cpp:
...
- Rely more on <alloc> declarations in Libraries
- Removed unreachable debug message
- Simplified code
2015-11-19 17:34:17 +01:00
PKEuS
0d25a43a5d
checkmemoryleak.cpp: Refactorized CheckMemoryLeakNoVar::check() and replaced a redundant whitelist by CheckMemoryLeakInFunction::test_white_list()
2015-11-19 17:34:17 +01:00
PKEuS
ab171fc027
Fixed false negatives in CheckMemoryLeakStructMember::checkStructVariable():
...
- Use generic detection of allocation/deallocation (#4770 )
- Make the checker usable for C++ by checking for destructors
- Reduced unit test duplication
2015-11-19 16:10:26 +01:00
PKEuS
db6174bb60
Refactorization: Support Types that consist of more than a single token in CheckMemoryLeakNoVar::checkForUnsafeArgAlloc
...
Removed obsolete comments
2015-11-19 16:10:26 +01:00
PKEuS
87d3ed91ab
Refactorization:
...
- Improved and cleaned up CheckMemoryLeak::functionReturnType()
- Cleaned up whitelist from functions declared as <leak-ignore/> in std.cfg
2015-11-18 22:09:27 +01:00
PKEuS
6ee4cf80dc
Improved detection of new operator in checkmemoryleak.cpp, fixed TODO unit test
2015-11-18 20:33:39 +01:00
Daniel Marjamäki
0f9d90d2be
Changed Copyrights. Removed my name.
2015-11-18 20:04:50 +01:00
PKEuS
6336372fb4
Apply same heuristics in CheckMemoryLeakNoVar::checkForUnusedReturnValue() as in CheckOther::checkIgnoredReturnValue(): Ensure that a defined function has non-void return value. ( #6693 )
2015-11-10 14:19:45 +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
PKEuS
07b661ef62
Refactorization: Improved handling of preprocessor in test suite
...
- Set Preprocessor::macroChar to '$' once in the beginning to avoid problems when changing the order of tests
- Removed Preprocessor usage from where it is not required
- Fixed a TODO in testuninitvar.cpp
2015-10-07 14:18:57 +02:00
PKEuS
ab8afec3eb
Refactorizations:
...
- Avoid unnecessary loop iterations
- Avoid unnecessary condition checking
- Reduced code duplication in symboldatabase.cpp
2015-08-16 14:23:07 +02:00
Martin Ettl
716b4d6e18
Another attempt to fix the current travis build. Improved testing of std.cfg.
2015-08-16 01:21:11 +02:00
Martin Ettl
ab0862f218
std.cfg: Fixed travis build. Added noreturn to the assert-definition in std.cfg. Improved testing of std.cfg.
2015-08-16 01:09:03 +02:00
Matthias Krüger
8bfbb5d09c
CheckMemoryLeakNoVar::returnValueNotUsedError: put function name into singlequotes
2015-07-31 15:29:07 +02:00
Alexander Mai
a36b544995
#3991 false positive: Memory leak (allocation function returns success/failed code). Add testcase. Issue had been fixed in 1.69 already
2015-07-25 18:50:27 +02:00
Simon Shanks
9910c1fa0c
Fixed #6617 (preprocessor performance improvement)
2015-07-24 13:30:41 +02:00
Daniel Marjamäki
234669b02b
Removed the UninitVar::analyseFunctions(). This was written for multifile checking however it did not work as it should => no multifile errors can be detected.
2015-07-24 08:30:38 +02:00
Alexander Mai
2c73518e29
Fix platform-dependent test result, formatting and crash in whole program analysis
2015-06-28 17:54:48 +02:00
amai2012
4a47b8b3ae
Refactoring: Better distinguish between C and C++ in a few checks.
2015-06-28 16:49:16 +02:00
Simon Martin
cba0583045
Ticket #6536 : Properly handle variables whose name is that of an allocation function.
2015-06-19 23:48:40 +02:00
PKEuS
4e5c5eb238
Fixed #5665 : Recognize free() with more than one parameter
2015-04-09 20:50:19 +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
fe8ba51f03
TestMemLeak: moved posix.cfg tests
2015-02-15 18:11:09 +01:00
Daniel Marjamäki
adedb5a888
TestMemLeakInFunction: Moved test to cfg test
2015-02-15 15:56:05 +01:00
PKEuS
54b6b8e571
Fixed false positive #6481
2015-01-31 20:34:06 +01:00
PKEuS
ae4b86c231
Several improvements to CheckMemoryLeakNoVar::checkForUnusedReturnValue():
...
- Support user defined functions (solves TODO tests)
- Print message if return value is not stored properly (adapted message text, #6458 )
2015-01-31 17:28:03 +01:00
PKEuS
03e44d4aa0
CheckMemoryLeakInFunction: Don't treat delete as delete operator for C code
...
Fixed GCC message in checkbufferoverrun.cpp
2015-01-30 20:55:53 +01:00
PKEuS
3274a00b82
Moved some more tests to testgarbage.cpp
2015-01-21 10:04:46 +01:00
Martin Ettl
910af75e3a
testmemleak: Added missing () in test case.
2015-01-11 10:27:37 +01:00
Martin Ettl
37c89a6b70
Fixed #6311 : Add support for GNU get_current_dir_name().
2015-01-11 10:12:39 +01:00
Daniel Marjamäki
a80101f277
CheckMemoryLeak: Fix FP for allocation functions that register memory before returning it
2015-01-05 13:23:38 +01:00
Daniel Marjamäki
f94243f85e
CheckMemoryLeak: Fix fp for allocation function that returns success value
2015-01-04 11:46:26 +01:00
Zachary Blair
22bd20c94a
New check: Use make_shared/make_unique ( #5673 )
2015-01-04 11:07:53 +01:00
Daniel Marjamäki
ff11ba9847
Updated copyright year to 2015
2015-01-03 12:14:58 +01:00
Thomas Jarosch
6b78ae7c46
Add mmap() / mmap64() / munmap() to posix.cfg. Enables basic leak tracking
...
Includes function prototype in posix.cfg as comment
for easier overview of the function arguments.
2014-12-14 13:30:24 +01:00
orbitcowboy
ac4f7879db
posix.cfg: Added support for rewinddir().
2014-12-10 16:10:03 +01:00
Thomas Jarosch
269a4419f0
Fixed false positives about strdupa() / strndupa() memleak
...
strdupa() / strndupa() allocates memory on the stack using alloca().
This memory is freed automatically once the current function is left.
2014-12-10 22:23:52 +01:00
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