Daniel Marjamäki
4998248501
Null pointers: Fixed false positives when running whole program analysis. Copied the fix from the CheckUninitVar::isUnsafeFunction.
2018-02-04 15:29:57 +01:00
Jørgen Kvalsvik
a61f21d1b6
Accept nested templates in tokenizer-simplify ( #1070 )
...
The following snippet triggerd the error:
template<typename DerivedT>
template<typename T>
auto ComposableParserImpl<DerivedT>::operator|( T const &other ) const -> Parser {
return Parser() | static_cast<DerivedT const &>( *this ) | other;
}
Whenever simplifyFunctionParameters was called on a templated class'
templated member function (and probably any nested template), the
tokenizer would recognise it as a syntax error, assuming that return
type *must* come after a template<> token.
2018-02-04 09:48:37 +01:00
Daniel Marjamäki
d47b7726fa
Uninitialized variables: Fix potential false positives in subfunction if there is early return or conditional writes
2018-02-04 09:40:57 +01:00
Daniel Marjamäki
1fe59faecb
changed message ids for uninitvar/nullpointer errors that was found by whole program analysis
2018-02-03 16:05:07 +01:00
IOBYTE
d721c6aca5
Fixed #8386 (syntax error not found (segmentation fault)) ( #1081 )
2018-02-03 15:50:05 +01:00
orbitcowboy
82c963d3a2
symboldatabase: Fix null pointer dereference, introduced by ee1ba85e15 (comments)
.
2018-02-02 08:45:13 +01:00
orbitcowboy
ee1ba85e15
symboldatabase: Fix potential null pointer dereference ( #1072 )
...
There is a potential `nullPointer` dereference in symboldatabase. This PR attempts to fix this. Additionally, this could be detected by Cppcheck as well.
Here is a reduced and compilable testcase, where Cppcheck fails to detect a potential `nullPointer` dereference:
```
class Scope
{
public:
bool bar();
int *definedType;
};
int f(Scope *new_scope)
{
int ret = 1;
if (new_scope)
{
if (new_scope->bar())
{
if (!new_scope->definedType) {} // check for null
ret = *new_scope->definedType; // dereference
}
}
return ret;
}
```
The corresponding ticket on track, addressing the false negative: https://trac.cppcheck.net/ticket/8375
2018-01-31 11:00:42 +01:00
orbitcowboy
f5e6ef9fd2
checkio: Fixed potential usage of invalid iterator. ( #1066 )
...
* checkio: Fixed potential usage of invalid iterator.
* formatted the code.
A ticket about FN (invalidIterator1) is created at https://trac.cppcheck.net/ticket/8373
2018-01-30 08:43:15 +01:00
Daniel Marjamäki
f5a11a6510
UninitVar: Speedup whole program analysis a bit
2018-01-29 15:15:35 +01:00
orbitcowboy
fb7f1efc49
token: Fixed potential null pointer dereference. ( #1062 )
2018-01-28 14:27:01 +01:00
Daniel Marjamäki
21a35de0d2
Tokenizer: Refactoring garbage check
2018-01-27 22:26:43 +01:00
David Hallas
4d18d3948f
Fixes issue with case inside switch that is not a compound statement ( #1031 )
...
* Fixes issue with case inside switch that is not a compound statement was treated as garbage
This fixes an issue with the check for case keywords outside of switch
detection that would treat a case statement inside a switch that is not
a compound statement as garbage, but this is perfectly valid C++. This
construct is used in several libraries, i.e. Google Test.
* Tweak check and handle missing semicolon
Tweaks the check with feedback from danmar.
Handle the case where there is no semicolon and document it with a unit
test.
2018-01-27 22:21:26 +01:00
Daniel Marjamäki
5b6ec49a6f
Pointer overflow: Fixed false positive
2018-01-27 22:09:43 +01:00
Daniel Marjamäki
189e0b3890
Fix Cppcheck warning about uninitialized variable
2018-01-27 22:05:29 +01:00
Daniel Marjamäki
bc40f5041d
Fixed #6356 (Improve checking: pointer arithmetic "ab.a + 100" overrun)
2018-01-27 15:39:39 +01:00
Daniel Marjamäki
c110770481
Fixed #8325 (False negative: address of auto variable being returned when assigned to another variable first)
2018-01-27 14:48:45 +01:00
orbitcowboy
27d9aaa8f5
checkother: Removed statement that is always true. ( #1059 )
2018-01-26 22:49:07 +01:00
Simon Martin
71ba513bdb
Ticket #8361 : Fix false positive in Tokenizer::findGarbageCode. ( #1061 )
2018-01-26 22:06:07 +01:00
Daniel Marjamäki
3ebedcd7f5
Fixed VS crash for torture test
2018-01-26 16:05:43 +01:00
Daniel Marjamäki
a5f202360a
Fixed crash for garbage code, found by fuzzing
2018-01-26 09:34:27 +01:00
Daniel Marjamäki
cb297a00fc
Auto variables: Assign address of local variable to global pointer ( #6825 )
2018-01-25 22:50:41 +01:00
Daniel Marjamäki
9109956c8c
UninitVar: Improve whole program analysis, used isVariableUsage()
2018-01-25 21:49:21 +01:00
Daniel Marjamäki
51c2ded23f
Fix crash
2018-01-25 19:42:50 +01:00
Daniel Marjamäki
1b3248b0fc
Dont write syntax error for lambda functions
2018-01-25 17:47:27 +01:00
Daniel Marjamäki
4d66609173
Fix Cppcheck warning, uninitialized member variable
2018-01-25 17:29:08 +01:00
Daniel Marjamäki
f73da16e94
Revert "UninitVar: Better checking in whole program analysis"
...
This reverts commit b2bdc2687b
.
2018-01-25 17:05:57 +01:00
Daniel Marjamäki
b2bdc2687b
UninitVar: Better checking in whole program analysis
2018-01-25 15:56:46 +01:00
Daniel Marjamäki
c04557eb73
Fix crashes detected with fuzzing
2018-01-25 15:53:58 +01:00
Daniel Marjamäki
ce60b326f4
Whole program analysis: Improved handling of nested calls
2018-01-24 22:53:14 +01:00
Daniel Marjamäki
599e038282
AutoVariables: Warn when address of local array is assigned to global pointer and pointer is not reassigned
2018-01-24 21:33:58 +01:00
IOBYTE
8ce496a127
Fix possible null pointer dereference cppcheck warning. ( #1056 )
2018-01-24 21:19:52 +01:00
Daniel Marjamäki
96e387a486
Fixed #8351 (segmentation fault on objective C code)
2018-01-24 18:06:11 +01:00
IOBYTE
558e0757c2
Fix simplifyTypedef crash on lambda. ( #1054 )
2018-01-24 15:04:33 +01:00
Daniel Marjamäki
0f561d0ed6
Fix crashes for garbage code, found by fuzzing
2018-01-24 13:53:03 +01:00
IOBYTE
4710d80a40
Fix #5766 (FP: typedef array throws off parser) ( #1052 )
...
* Fix #5766 (FP: typedef array throws off parser)
* Fix travis build.
2018-01-24 09:51:22 +01:00
IOBYTE
e6d285d3ca
Fixed #8357 (crash: cmake Tests/CMakeLib/testUTF8.cxx --debug --verbose) ( #1046 )
2018-01-22 08:06:56 +01:00
Daniel Marjamäki
512b9f512c
Refactoring whole program analysis for CheckUninitVar and CheckNullPointer
2018-01-21 22:56:46 +01:00
IOBYTE
3159d151d3
Fix symbol database crash on template type aliases by ignoring them. ( #1045 )
2018-01-21 21:22:26 +01:00
Daniel Marjamäki
351b382a7b
Null pointers: Whole program analysis
2018-01-21 19:51:15 +01:00
Martin Ettl
17a54681b8
tokenize: simplify empty string creation string("")->string().
2018-01-21 16:36:57 +01:00
Alexey Eryomenko
913fdf44b6
member access operators are allowed inside the embedded SQL block when ( #1043 )
...
passing arguments for a query
2018-01-21 15:58:12 +01:00
Daniel Marjamäki
ea63e52d98
UninitVar: Improved function/method matching in whole program analysis
2018-01-21 10:40:35 +01:00
IOBYTE
5673348215
Fixed #8350 (False positive: enum class static_cast to int is treated as non-primitive when type inference is used) ( #1042 )
2018-01-21 07:26:37 +01:00
orbitcowboy
ec0cc4e29c
templatesimplifier: Removed redundant local string variable. ( #1041 )
2018-01-20 22:26:48 +01:00
orbitcowboy
bf201328d1
Merge pull request #1039 from orbitcowboy/master
...
checkstring: Cleanup not needed variable.
2018-01-20 14:59:01 +01:00
Simon Martin
b4f32206af
Ticket #8337 : Fix false positive in copy constructor detection. ( #1040 )
2018-01-20 14:46:09 +01:00
Martin Ettl
9816358e8b
Cleanup not needed variable.
2018-01-19 22:41:51 +01:00
Simon Martin
8878e6dd0d
Ticket #8333 : Properly report a syntax error for functions with invalid parameter types. ( #1030 )
2018-01-18 08:51:35 +01:00
Daniel Marjamäki
c7c9b3cd65
Fixed Cppcheck warning about using const reference to avoid data copying
2018-01-15 22:31:15 +01:00
Daniel Marjamäki
a0a04be011
Fix Cppcheck warning about mismatching argument names
2018-01-15 22:25:55 +01:00