Commit Graph

1190 Commits

Author SHA1 Message Date
Paul Fultz II 45b4580554
Fix 10957: Crash on valid code (#3991) 2022-04-10 22:47:58 +02:00
Oliver Stöneberg 25ef9eeb26
use std::string::empty() (#3910) 2022-04-09 19:02:37 +02:00
Paul Fultz II 4c1aeb0cb1
Remove old pointer alias check (#3983) 2022-04-07 11:36:15 +02:00
chrchr-github 52b4aeb279
Fix #10792 FP knownConditionTrueFalse with double to int cast (#3964) 2022-04-07 10:42:57 +02:00
Paul Fultz II dad10f2ab7
Fix 7684: ValueFlow: function call 'X::GetSize()' (#3984)
* Improve getting function to calculate the return

* Add test

* Format

* Move to cpp to avoid FP

* Format
2022-04-07 06:49:25 +02:00
Paul Fultz II 74667d1e2a
Fix 10418: false negative: knownConditionTrueFalse (#3981)
* Improve handling inverted condition

* Fix tests

* Rename variables for clarity

* Add initial test

* Add another test

* Format

* Fix FP
2022-04-07 06:48:13 +02:00
Paul Fultz II bb640c4879
Fix 10950: Crash on function declaration (#3979)
* Fix 10950: Crash on function declaration

* Format
2022-04-06 19:00:05 +02:00
Paul Fultz II 4fde7f8b18
Fix 10449: Regression: knownConditionTrueFalse (strlen/wcslen) (#3977)
* Refactor library function usage

* Evaluate library function in program memory

* Fix and add tests

* Format
2022-04-06 06:35:38 +02:00
Paul Fultz II 1d92665ad2
Fix 10867: false negative: containerOutOfBounds with std::array (regression) (#3976)
* Fix 10867: false negative: containerOutOfBounds with std::array (regression)

* Format
2022-04-06 06:25:28 +02:00
chrchr-github cfbbeb4b1b
Partial fix for #10867 FN containerOutOfBounds with std::array (#3971)
* Partial fix for #10867 FN containerOutOfBounds with std::array

* Format

* Format

* Optimize
2022-04-05 07:34:20 +02:00
Paul Fultz II 0547cbcd26
Fix 10647: FN knownConditionTrueFalse for impossible Boolean value (#3968)
* Add impossible values for bool

* Fix valueflow tests

* Fix assertion failure

* Add test

* Format
2022-04-03 20:04:05 +02:00
chrchr-github 4bf8718dcb
Fix #10849 FP constStatement with pointers in lambda (#3961) 2022-04-01 19:50:40 +02:00
Paul Fultz II 32ded1602b
Fix warnings in switch statements on clang (#3943) 2022-03-30 19:30:02 +02:00
Paul Fultz II 21b8c36eb1
Fix 10916: FP: uninitvar (#3949) 2022-03-27 10:01:58 +02:00
chrchr-github 479af21405
Fix #10698 FP uninitvar with new and braced initializer (#3934) 2022-03-24 20:08:51 +01:00
Paul Fultz II 4b4037540a
valueFlowUninit: Handle arrays and pod types (#3917)
* valueFlowUninit: Handle arrays and pod types

* Format

* Catch another array case
2022-03-24 06:35:44 +01:00
chrchr-github 3faff5e9fc
Fix #10248 FP knownConditionTrueFalse static variable with direct initialization (#3922) 2022-03-22 07:24:40 +01:00
chrchr-github 0e147502cc
Fix #10888 FN variableScope with enum and struct (#3920)
* Fix #10888 FN variableScope with enum and struct

* Scope reduction

* Scope reduction
2022-03-21 16:05:38 +01:00
Paul Fultz II 40ff9edad6
Fix 10843: FP: danglingTemporaryLifetime (#3908)
* Fix 10843: FP: danglingTemporaryLifetime

* Format
2022-03-16 17:11:49 +01:00
Armin Müller 7cc45fb393
Typos found by running "codespell" (#3907)
Co-authored-by: Armin Müller <mueller.armin@foestergroup.de>
2022-03-16 15:28:44 +01:00
Oliver Stöneberg 0d336b868c
avoid some Clang compiler warnings (#3896) 2022-03-13 20:07:58 +01:00
Oliver Stöneberg 757287b13c
removed unnecessary varid0 inline suppressions (#3893) 2022-03-12 18:02:40 +01:00
Paul Fultz II ff902369e0
Fix 10851: False positive: known variable value below for loop (#3891)
* Fix 10851: False positive: known variable value below for loop

* Format

* Add test for 10863

* Format
2022-03-12 06:15:35 +01:00
chrchr-github fbdfb60809
Warn about buffer overruns when allocating memory with new (#3879)
* Warn about buffer overruns when allocating memory with new

* Format

* Avoid FP
2022-03-07 19:43:40 +01:00
chrchr-github 7f682d544e
Partial fix for #6615 FN buffer access out of bounds: std::vector (#3873)
* Fix #10779 FN: stlOutOfBounds (off by one)

* Format

* Simplify

* Partial fix for #6615 FN buffer access out of bounds: std::vector

* Undo

* Format

* Fix test case
2022-03-06 07:41:09 +01:00
chrchr-github 27baa20f38
Fix #10779 FN: stlOutOfBounds (off by one) (#3872)
* Fix #10779 FN: stlOutOfBounds (off by one)

* Format

* Simplify
2022-03-04 17:13:13 +01:00
chrchr-github 2dd6c75b35
Fix #10838 Crash/nullptr deref in getEndOfExprScope() (#3870)
* Fix #10838 Crash/nullptr deref in getEndOfExprScope()

* Format
2022-03-03 17:08:23 +01:00
Daniel Marjamäki 915ae4b845 ValueFlow: Fix crash 2022-03-02 21:12:37 +01:00
Oliver Stöneberg 4a63af02ed
enabled functionConst and functionStatic in selfcheck (#3862)
* fixed functionConst findings and enabled it in selfcheck

* fixed functionStatic findings and enabled it in selfcheck

* .travis_suppressions: adjusted comment

* testimportproject.cpp: added missing asserts
2022-03-02 07:46:47 +01:00
Paul Fultz II 0b310b9d07
Fix 10702: FP knownConditionTrueFalse - Member variable modified (#3857)
* Fix 10702: FP knownConditionTrueFalse - Member variable modified

* Format

* Make parameter const

* Fix FP

* Fix FP

* Update

* Format
2022-02-28 18:54:55 +01:00
chrchr-github d79d6e60db
Fix #10828 Internal error. Token::Match called with varid 0 (#3859)
* Fix #10828 Internal error. Token::Match called with varid 0

* Fix test
2022-02-26 23:48:29 +01:00
Paul Fultz II dbc80787e1
Fix 10821: FN: containerOutOfBounds (#3856)
* Fix 10821: FN: containerOutOfBounds

* Format

* Fix cppcheck warning

* Add valueflow tests

* Format

* Fix some bugs

* Format
2022-02-25 05:53:51 +01:00
Paul Fultz II 45de9a7d08
Refactor: Use getEndOfExprScope instead of getEndOfVarScope (#3855) 2022-02-24 06:50:34 +01:00
chrchr-github 172aafdeb8
Fix #7908 FN: redundant assignment in loop (#3650) 2022-02-22 09:51:44 +01:00
Paul Fultz II 1ac16413ea
Another fix for 10800: Hang / memory exhaustion on numerical code (#3851)
* Another fix for 10800: Hang / memory exhaustion on numerical code

* Format
2022-02-22 07:21:26 +01:00
Oliver Stöneberg b6876d22e6
use inline suppressions for varid0 in selfcheck (#3842) 2022-02-21 18:35:02 +01:00
chrchr-github 734e3ac6da
Fix cppcheckError with for loop (#3847) 2022-02-21 18:14:20 +01:00
chrchr-github 6635e6cc07
Fix #10795 cppcheckError with for loop (#3841) 2022-02-17 22:12:19 +01:00
Paul Fultz II 78228599da
Fix 10800: Hang / memory exhaustion on numerical code (#3822)
* Fix 10800: Hang / memory exhaustion on numerical code

* Format

* Add another test

* Format
2022-02-11 06:52:28 +01:00
Oliver Stöneberg f32583e097
removed OVERRIDE and FINAL defines and use the keywords directly (#3767) 2022-02-10 23:02:24 +01:00
chrchr-github 24e9859158
Fix #10357 FP stlcstrParam due to incorrect overload resolution (#3813)
* Fix #10357 FP stlcstrParam due to incorrect overload resolution

* Variable shadowing
2022-02-10 11:17:06 +01:00
Paul Fultz II a50452517d
Fix 10794: Crash in MultiValueFlowAnalyzer::getProgramState() (#3815)
* Fix 10794: Crash in MultiValueFlowAnalyzer::getProgramState()

* Format
2022-02-10 07:43:27 +01:00
Paul Fultz II 20a5224d7e
Fix 10784: False positive: returnDanglingLifetime using std::tie with variadic template parameters (#3805) 2022-02-08 09:03:51 +01:00
Paul Fultz II f2a419653c
Refactor ProgramMemory to store the expression tokens instead of exprIds (#3798) 2022-02-06 20:15:45 +01:00
Paul Fultz II 569332a50a
Fix 10786: False positive: arrayIndexOutOfBoundsCond (#3803) 2022-02-06 20:14:13 +01:00
Daniel Marjamäki 3989408738 Update copyright year 2022-02-05 11:45:17 +01:00
Paul Fultz II 11387cbb41
Fix 10768: performance regression (#3788) 2022-02-02 13:01:44 +01:00
Oliver Stöneberg 171da2e6f9
avoid dependency on transitive includes - based on include-what-you-use (#3757) 2022-01-27 19:03:20 +01:00
Paul Fultz II 40147c1e4b
Fix 10719: Crash in valueFlowIterators() (#3756)
* Fix 10719: Crash in valueFlowIterators()

* Format
2022-01-26 06:42:41 +01:00
Paul Fultz II 0737cc4d8c
Fix 10708: Assertion "!maxValue->isKnown()" from valueFlowInferCondition (#3736)
* Fix 10708: Assertion "!maxValue->isKnown()" from valueFlowInferCondition

* Format
2022-01-21 09:56:24 +01:00
Paul Fultz II 7b793af451
Fix 10728: Crash in CheckStl::checkDereferenceInvalidIterator2 (#3721)
* Fix 10728: Crash in CheckStl::checkDereferenceInvalidIterator2

* Format
2022-01-18 14:48:02 +01:00
Armin Müller 5a05631c84
Typos found by running "codespell" (#3702) 2022-01-13 17:24:26 +01:00
Paul Fultz II 4ef20f8f1e
Fix 10683: FP danglingTemporaryLifetime with pointer to vector (#3685) 2022-01-10 07:34:26 +01:00
Paul Fultz II fe7595cd9d
Fix 10677: crash during valueFlowInferCondition (#3687) 2022-01-09 22:43:08 +01:00
Paul Fultz II 0c9eb5d190
Fix 10681: FP ctuuninitvar with array member (#3686) 2022-01-08 10:47:28 +01:00
Oliver Stöneberg 0ba9cb4e64
fixed some unusedFunction warnings (#3618) 2022-01-04 15:48:08 +01:00
Paul Fultz II 50862d1ace
Fix 10665: Crash in ExpressionAnalyzer (#3661) 2022-01-02 08:09:23 +01:00
Paul Fultz II 0c952ca05d
Fix 10223: ValueFlow; known value for a volatile variable (#3658) 2022-01-01 23:15:14 +01:00
Paul Fultz II 73f24b43f9
Fix 10437: FP knownConditionTrueFalse after pointer check (#3646) 2021-12-20 07:28:40 +01:00
Paul Fultz II e7db974606
Fix 10621: FP arrayIndexOutOfBoundsCond with multiple index checks (#3640) 2021-12-17 21:48:29 +01:00
Paul Fultz II 4fb43a3f56
Fix 10643: FP: (error) Array 'buf[64]' accessed at index -1, which is out of bounds. (#3639)
* Fix 10643: FP: (error) Array 'buf[64]' accessed at index -1, which is out of bounds.

* Format
2021-12-17 10:05:57 +01:00
Paul Fultz II 398fa28021
Fix 10657: False positive; ValueFlow - invalid iterator (#3636) 2021-12-16 22:34:51 +01:00
Oliver Stöneberg ba402f3e50
cleaned up includes based on include-what-you-use (#3627) 2021-12-15 19:47:27 +01:00
Paul Fultz II 5414814238
Fix 10649: False positive: wrong known value after reassignment (#3631) 2021-12-15 19:37:25 +01:00
Paul Fultz II 6681576707
Fix 10642: False positive: Possible dereference of an invalid iterator: v.begin()+v.size()-1 (#3630) 2021-12-15 19:31:28 +01:00
chrchr-github 532477cdb2
Fix #9549 FP knownConditionTrueFalse (bitshift) (#3616) 2021-12-14 07:30:57 +01:00
Paul Fultz II 3874c546cc
Fix 10641: FP invalidLifetime with compiler-generated constructor (#3609) 2021-12-07 07:43:25 +01:00
Paul Fultz II d2926bfa96
ValueFlow: Propagate const variables more aggressively (#3606)
* ValueFlow: Propagate const variables more aggressively

* Format

* Fix incorrect addition
2021-12-06 09:16:42 +01:00
Paul Fultz II f64bcac004
Fix 10429: Regression: invalidIterator (#3603) 2021-12-05 15:46:52 +01:00
Paul Fultz II a03e731930
Track lifetimes of lambdas that capture the 'this' variable (#3594) 2021-12-04 17:00:55 +01:00
Paul Fultz II c14920218c
Fix 10624: FP knownConditionTrueFalse with pointer member and dynamic cast (#3598) 2021-12-04 08:54:24 +01:00
Paul Fultz II a0d633945e
Fix 10621: FP arrayIndexOutOfBoundsCond with multiple index checks (#3597)
* Fix 10621: FP arrayIndexOutOfBoundsCond with multiple index checks

* Format
2021-12-04 08:54:04 +01:00
Paul Fultz II 57f5b19b34
Fix 7812: False negative: return pointer of local variable (#3583)
* Fix 7812: False negative: return pointer of local variable

* Format

* Add test case for 3029

* Format
2021-11-28 15:25:21 +01:00
Paul Fultz II 143ddf2758
Fix 10595: FN: std::vector() reserve() (#3581)
* Fix 10595: FN: std::vector() reserve()

* Format
2021-11-26 09:50:02 +01:00
Paul Fultz II 12e731ad49
Fix 10605: FP containerOutOfBounds with empty() check (#3572) 2021-11-25 22:34:00 +01:00
Paul Fultz II 33ad30f4da
Fix 10617, 9824: conditions in expanded macro (#3578) 2021-11-25 18:40:15 +01:00
Paul Fultz II a0d3c2c719
Handle for loop conditions in afterCondition (#3561) 2021-11-14 18:30:36 +01:00
Paul Fultz II 112363c9d1
Fix 10590: container access out of bounds not found (#3560)
* Refactor container bounds check

* Use symbolic values

* Add test case

* Format
2021-11-13 07:45:29 +01:00
Paul Fultz II c057dcce0f
Fix 10592: False positive: returnDanglingLifetime (#3557) 2021-11-11 08:00:05 +01:00
Paul Fultz II 035c70c441
Fix 10578: Value not impossible after check (#3549) 2021-11-07 18:19:56 +01:00
Paul Fultz II 1791457227
Fix 9953: false positive: uninitvar (#3548) 2021-11-07 06:51:19 +01:00
Paul Fultz II 6338c2396c
Fix 10589: False positive: danglingLifetime for moved unique ptr (#3547) 2021-11-06 19:08:19 +01:00
Paul Fultz II ffc2a9d8e2
Fix 9735 for valueFlowUninit (#3538) 2021-11-06 19:06:07 +01:00
Daniel Marjamäki 0f259a5dc6 Fixed #10222 (regression: arrayIndexOutOfBounds) 2021-11-03 20:16:44 +01:00
Paul Fultz II d3f0aa5b34
Fix 10033: false negative: danglingTemporaryLifetime with usage of reference from nested object not detected (#3542) 2021-11-01 19:23:15 +01:00
Paul Fultz II be14866095
Run valueFlowSubfunction in reverse order of functions (#3540) 2021-11-01 19:21:03 +01:00
Paul Fultz II 04ecf53a07
Use static array to store iterator infer models instead of constructing a vector everytime (#3539) 2021-11-01 19:18:18 +01:00
Paul Fultz II df59b07ba1
Fix 10226: FN: knownConditionTrueFalse (#3537) 2021-10-31 14:51:07 +01:00
Paul Fultz II 8c9c46835a
Fix for 6597: false negative: uninitialized variable usage not detected (ValueFlow , multi variables) (#3535) 2021-10-30 22:13:58 +02:00
Paul Fultz II e20ddd55d6
Propagate partially uninit variables in ValueFlow (#3533) 2021-10-30 07:43:37 +02:00
Paul Fultz II 48fc70b810
Dont stop analysis when an unrelated class variable is changed (#3518) 2021-10-23 14:47:10 +02:00
Paul Fultz II ca83222bae
Add subexpression analyzer to set values for uninitialized members of struct (#3517)
* Add subexpression analyzer

* Fix errors

* Add tests

* Format

* Add more tests

* Run members first

* Format

* Uncomment todo assert

* Formatting

* Use simpleMatch
2021-10-21 14:44:48 +02:00
chrchr-github c88dceff95
Partial fix for #10358: set value for int s{ 4 }; (#3506) 2021-10-15 20:05:42 +02:00
Paul Fultz II 89515600e4
Fix 10538: FN: nullPointer (std::swap pointers) (#3504) 2021-10-15 10:58:16 +02:00
Paul Fultz II 130d1abbce
Fix 10210: FN: nullPointerRedundantCheck regression in member function (#3512) 2021-10-15 10:57:40 +02:00
Paul Fultz II f1f86db0da
Fix 10544: FP knownConditionTrueFalse with loop after check (#3508) 2021-10-14 16:47:15 +02:00
Paul Fultz II 6b9ef1fc58
Propagate symbolic values for identity operators (#3497) 2021-10-14 16:46:36 +02:00
Oliver Stöneberg 99db1f3f22
fixed some compiler warnings (#3502) 2021-10-13 12:10:26 +02:00
Paul Fultz II 52e4bec50a
Fix 10537: FN: knownConditionTrueFalse (std::string::c_str() never returns nullptr) (#3498) 2021-10-11 19:16:12 +02:00
Paul Fultz II 5e9bc48d26
Evaluate symbolic values (#3495) 2021-10-11 19:10:37 +02:00