File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11void test (char *arg1, int *arg2) {
22 if (arg1[0 ] == ' A' ) {
3- if (arg2 != NULL ) {
3+ if (arg2 != NULL ) { // maybe redundant
44 *arg2 = 42 ;
55 }
66 }
77 if (arg1[1 ] == ' B' )
88 {
9- *arg2 = 54 ;
9+ *arg2 = 54 ; // dereferenced without checking first
1010 }
1111}
Original file line number Diff line number Diff line change 1313
1414import cpp
1515
16- predicate blockDominates ( Block check , Block access ) {
17- check .getLocation ( ) .getStartLine ( ) <= access .getLocation ( ) .getStartLine ( ) and
18- check .getLocation ( ) .getEndLine ( ) >= access .getLocation ( ) .getEndLine ( )
19- }
20-
2116predicate isCheckedInstruction ( VariableAccess unchecked , VariableAccess checked ) {
2217 checked =
2318 any ( VariableAccess va |
2419 va .getTarget ( ) = unchecked .getTarget ( )
2520 ) and
2621//Simple test if the first access in this code path is dereferenced
2722 not dereferenced ( checked ) and
28- blockDominates ( checked .getEnclosingBlock ( ) , unchecked .getEnclosingBlock ( ) )
23+ bbDominates ( checked .getBasicBlock ( ) , unchecked .getBasicBlock ( ) )
2924}
3025
3126predicate candidateResultUnchecked ( VariableAccess unchecked ) {
You can’t perform that action at this time.
0 commit comments