Commit Graph

517 Commits

Author SHA1 Message Date
Roberto Martelloni e89cd1b8a4 CWE mapping of unsafeClassCanLeak, zerodivcond, invalidPointerCast, redundantCopy, redundantAssignment, comparisonFunctionIsAlwaysTrueOrFalse, checkCastIntToCharAndBack, cstyleCast, passedByValue, clarifyCondition, exceptThrowInDestructor, exceptDeallocThrow, exceptRethrowCopy, catchExceptionByValue, fflushOnInputStream, seekOnAppendedFile, publicAllocationError
CWE mapping of unsafeClassCanLeak, zerodivcond, invalidPointerCast, redundantCopy, redundantAssignment, comparisonFunctionIsAlwaysTrueOrFalse, checkCastIntToCharAndBack, cstyleCast, passedByValue, clarifyCondition, exceptThrowInDestructor, exceptDeallocThrow, exceptRethrowCopy, catchExceptionByValue, fflushOnInputStream, seekOnAppendedFile, publicAllocationError
2016-04-12 19:29:40 +02:00
Alexander Mai 0533d7bf9c Run astyle + minor refactoring 2016-02-27 16:03:50 +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 5e10e680da CWE: refactoring. use constants instead of magic numbers. 2016-01-25 20:01:48 +01:00
Daniel Marjamäki 0fb9ab7b4a Refactoring CheckMemoryLeakNoVar::checkForUnusedReturnValue(). use continue 2016-01-25 10:33:11 +01:00
Roberto Martelloni 5ce69da02d Mapped 26 errors to their CWEs ID. 2016-01-24 20:53:05 +00:00
Daniel Marjamäki 642cc57428 CheckMemoryLeak: Fix FP when overloaded new is used 2016-01-20 10:34:03 +01:00
Daniel Marjamäki d39097f52a Removed redundant null pointer check 2016-01-16 14:15:51 +01:00
Roberto Martelloni 5c1965a6e0 Added mapped CWE IDs to reportErr function calls 2016-01-05 20:37:39 +01:00
Alexander Mai d6fd4705cf #7255 segmentation fault (invalid code) in CheckMemoryLeakInFunction::getcode 2016-01-03 20:53:03 +01:00
Daniel Marjamäki 79e663dd6f Settings: Remove '_' prefix for public member variables 2016-01-03 16:18:17 +01:00
Lauri Nurmi 996c9244d8 Update copyright year to 2007-2016. 2016-01-01 15:34:45 +02:00
PKEuS 940d569980 Refactorization: Removed redundant %any% patterns. 2015-12-24 14:40:48 +01:00
Alexander Mai 86c9387987 #7182 crash: CheckMemoryLeak::functionReturnType() 2015-12-05 18:43:29 +01:00
Alexander Mai e69377d5a8 #7183 CheckClass::checkMemset() uint overflow. Plus some minor refactoring 2015-12-05 18:22:01 +01:00
PKEuS e8522c7883 Small refactorizations:
- #include cleanup
- Use std::array instead of std::vector
- Do not create a stringstream to concatenate 4 strings
- Use std::cout instead of printf
2015-11-29 10:56:44 +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 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
Matthias Krüger 8faf8e2b25 fix internal warning:
[lib/checkmemoryleak.cpp:2722]: (warning) Found simple pattern inside Token::Match() call: "> ("
2015-11-19 17:03:55 +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 1566b72c5b Fixed broken AST for simple expressions with delete operator.
Fixed cppcheck internal warning
2015-11-18 21:37:37 +01:00
PKEuS 4957e48d7c Refactorization: Removed std::string overload of CheckMemoryLeak::getDeallocationType(), improved varid overload to handle member variables 2015-11-18 21:17:50 +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
Philipp Kloke 2a5206a444 Refactorization: Reordered conditions - simplematch is cheaper than findsimplematch 2015-10-19 09:01:21 +02:00
Dmitry-Me 773ee8c32a Better variable name, explicit no-op 2015-09-11 17:26:33 +03: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
PKEuS ee4a5843bb Some small refactorizations 2015-08-15 19:46:31 +02:00
Daniel Marjamäki e598b07a6d Moved functions to astutils 2015-08-03 09:20:50 +02:00
Matthias Krüger 8bfbb5d09c CheckMemoryLeakNoVar::returnValueNotUsedError: put function name into singlequotes 2015-07-31 15:29:07 +02:00
Daniel Marjamäki 4e293d47c5 CheckMemoryLeak: Fix handling of comparisons after simplifyIfNotNull is removed, detected problem with run_more_tests 2015-07-26 11:27:52 +02:00
Daniel Marjamäki e5151a13ab Fixed #6867 (False positive memleak) 2015-07-25 11:37:03 +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
Daniel Marjamäki b38062743d Refactoring handling of if conditions in CheckMemoryLeak 2015-07-22 16:45:14 +02:00
Daniel Marjamäki b2b4bb49fa Refactoring handling of comparisons 2015-07-22 12:31:18 +02:00
Daniel Marjamäki f9d22f70db Removed simplifyIfNot simplification (#6072) 2015-07-21 20:56:47 +02:00
Daniel Marjamäki 24269b1061 Refactoring CheckMemoryLeak::notvar, use AST instead of token parsing 2015-07-21 20:27:59 +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
Alexander Mai 4172011e78 Missing update for Makefile. CheckMemoryLeakInFunction::getcode(): skip some C++ token matching in C mode. Minor refactoring 2015-06-20 22:49:28 +02:00
Alexander Mai b3c7a3f798 Fix more (potential) multi-threading issues 2015-06-20 22:26:51 +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
Alexander Mai 13c1c2c035 Refactoring (use const std::set for strings). Omit some matching for C++ stuff within C code. 2015-06-17 22:28:15 +02:00
amai2012 f2d397882f #6753 segmentation fault (invalid code) in CheckMemoryLeakStructMember::checkStructVariable. #6754 segmentation fault (invalid code) in CheckUnusedVar::checkFunctionVariableUsage_iterateScopes. Trivial fixes to avoid null pointer access 2015-06-03 17:17:53 +02:00
Daniel Marjamäki 88f59ad7e8 Partial fix for #6656 (Allow that CWE is mapped for error message) 2015-04-25 17:48:11 +02:00
Matthias Krüger 42f0955e3f Move more setting checks out of loops and use const bools instead. Reorder a few related checks.
Follow up to eedcb6abcb .
2015-04-10 14:31:19 +02:00
PKEuS 4e5c5eb238 Fixed #5665: Recognize free() with more than one parameter 2015-04-09 20:50:19 +02:00
Matthias Krüger 6ff9a52d8b don't print style message if --enable=style is not given (#6627)
message was of type:
(style) Class 'foo' is unsafe, 'foo::bar' can leak by wrong usage.
2015-04-06 12:02:21 +02:00
Dmitry-Me aa7d665e7a Better variable name 2015-04-01 16:39:45 +03:00
Dmitry-Me 4201279954 Merge overlapping patterns 2015-03-24 10:22:26 +03:00
Dmitry-Me 848f50b005 Get rid of Hungarian notation 2015-02-27 12:02:12 +03:00
Daniel Marjamäki acbf48c7fa Fixed #6548 (Tokenizer: Wrong varid set after function which is throw()) 2015-02-26 16:31:42 +01:00
Dmitry-Me cc18b8d1bb Merge overlapping patterns 2015-02-05 17:30:49 +03: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 b2835051df Refactorization: Renamed Token::Match pattern %var% to %name%, implement new pattern %var% which is true if varId > 0. 2015-01-31 12:32:04 +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
Thomas Jarosch fd01cafb1b Clean up redundant pointer operations 2015-01-17 16:29:50 +01:00
PKEuS 7452613479 Refactorization:
- Merged messages exceptThrowInNoexecptFunction, exceptThrowInNoThrowFunction, exceptThrowInAttributeNoThrowFunction and exceptThrowInDeclspecNoThrowFunction into a single message.
- Merged Token::fIsDeclspecNothrow into Token::fIsAttributeNothrow
2015-01-09 20:18:09 +01:00
Daniel Marjamäki 6a8293a8b7 Library: More strict matching of functions 2015-01-08 19:31:41 +01:00
Robert Reif ba1c24ee65 Fixed #6422 (symbol database: put function flags into a single flag variable) 2015-01-08 05:45:31 +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 69b31a0743 Fix up extra whitespaces in match patterns
Detected by new internal check.
2014-12-30 14:53:43 +01:00
PKEuS 990d14f3e2 Fixed #6328: Use isAttributeNoreturn() whereever we also check Library::isnoreturn(). 2014-12-27 11:07:36 +01:00
Alexander Mai cef324435f Remove dead code in CheckMemoryLeakInFunction::call_func() (Coverity CID 1257017) 2014-12-09 20:34:30 +01:00
Frank Zingsheim 9497732ac8 Fixed #6238 (false positive with double fopen) 2014-11-20 22:19:39 +01:00
Dmitry-Me e12d280e90 Code cleanup. Omit redundant actions. 2014-11-18 06:38:19 +01:00
Daniel Marjamäki de7e9223b8 Fixed #6272 (Improve check: multifile checking in checkbufferoverrun) 2014-11-15 10:43:49 +01:00
Daniel Marjamäki 8012ac9562 Fixed #5993 (FP: memleak (linux list)) 2014-11-07 07:44:12 +01:00
PKEuS 662283cab8 Refactorization: Avoid iterations over whole token list, limited several checks to function scopes. 2014-10-31 11:42:54 +01: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 03b1afc28c Loops over all varIds should start at 1. 2014-09-28 09:47:11 +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 2d608890a5 Improved message 'mismatchSize' (#4167) 2014-09-02 09:38:40 +02:00
PKEuS 0995b85c09 Attempt to fix crashs when self-checking cppcheck introduced by previous commit 2014-09-01 14:12:43 +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
Dmitry-Me eace67ee1c Use logical instead of bitwise operators to save cpu 2014-08-30 11:35:25 +02:00
Dmitry-Me 9829e0b48a Clearer variable names, fix typo in comment. 2014-07-11 11:33:09 +04:00
Alexander Mai 0f7071a000 Fix clang and coverity warnings 2014-06-12 20:03:11 +02:00
PKEuS 01a0154daa Fixed false positive #5848 2014-05-21 13:45:36 +02:00
Daniel Marjamäki 01d14d0388 Library: Refactoring alloc/dealloc functions. Normally the token should be passed so extra validation can be made 2014-04-20 14:59:16 +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
Daniel Marjamäki b909aa0e4f CheckMemoryLeak: moved 'popen' into posix scope 2014-04-18 16:30:16 +02:00
Daniel Marjamäki d7e2e3bd5e Fixed #5502 (FP: Dereferencing 'b' after it is deallocated / released) 2014-04-06 18:45:24 +02:00
Daniel Marjamäki 06618b31bb Fixed #5574 (False positive: mismatchAllocDealloc using realloc() and free) 2014-03-17 16:10:54 +01:00
Lauri Nurmi 70a67eaf85 Change some more 0 literals into nullptr. 2014-02-16 13:38:50 +02:00
Daniel Marjamäki 209dffbe1b use nullptr in lib/checkmemoryleak.cpp 2014-02-15 16:17:56 +01:00
Daniel Marjamäki fd3a8a2a18 Update copyright 2014-02-15 07:45:39 +01:00
Pavel Roschin 0dd227419d CheckMemoryLeak: use library while checking whitelist functions 2014-02-05 12:16:50 +04:00