Skip to content

Commit 4d16b3b

Browse files
committed
Update OwnedPointerValueStoredInUnrelatedSmartPointer to the new dataflow library
Note this introduces some new results. This seems to be correct, as before the update the query seemed to have missed problems with code like the following: ```cpp void f3(int *v1) { int *v2 = v1; std::shared_ptr<int> p1(v1); // NON_COMPLIANT new std::shared_ptr<int>(p1.get()); // NON_COMPLIANT new std::shared_ptr<int>(v2); // NON_COMPLIANT } void f4() { f3(new int(0)); } ```
1 parent 146d85a commit 4d16b3b

File tree

2 files changed

+32
-12
lines changed

2 files changed

+32
-12
lines changed

cpp/common/src/codingstandards/cpp/rules/ownedpointervaluestoredinunrelatedsmartpointer/OwnedPointerValueStoredInUnrelatedSmartPointer.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import cpp
88
import codingstandards.cpp.Customizations
99
import codingstandards.cpp.Exclusions
1010
import codingstandards.cpp.SmartPointers
11-
import semmle.code.cpp.dataflow.TaintTracking
11+
import semmle.code.cpp.dataflow.new.TaintTracking
1212
import PointerToSmartPointerConstructorFlowFlow::PathGraph
1313

1414
abstract class OwnedPointerValueStoredInUnrelatedSmartPointerSharedQuery extends Query { }
Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,64 @@
11
problems
2+
| test.cpp:5:27:5:28 | v1 | test.cpp:4:13:4:14 | v1 | test.cpp:5:27:5:28 | v1 | Raw pointer flows to initialize multiple unrelated smart pointers. |
23
| test.cpp:5:27:5:28 | v1 | test.cpp:16:13:16:22 | new | test.cpp:5:27:5:28 | v1 | Raw pointer flows to initialize multiple unrelated smart pointers. |
4+
| test.cpp:6:31:6:33 | call to get | test.cpp:4:13:4:14 | v1 | test.cpp:6:31:6:33 | call to get | Raw pointer flows to initialize multiple unrelated smart pointers. |
35
| test.cpp:6:31:6:33 | call to get | test.cpp:16:13:16:22 | new | test.cpp:6:31:6:33 | call to get | Raw pointer flows to initialize multiple unrelated smart pointers. |
6+
| test.cpp:7:28:7:29 | v2 | test.cpp:4:13:4:14 | v1 | test.cpp:7:28:7:29 | v2 | Raw pointer flows to initialize multiple unrelated smart pointers. |
47
| test.cpp:7:28:7:29 | v2 | test.cpp:16:13:16:22 | new | test.cpp:7:28:7:29 | v2 | Raw pointer flows to initialize multiple unrelated smart pointers. |
58
| test.cpp:11:28:11:29 | v2 | test.cpp:10:8:10:17 | new | test.cpp:11:28:11:29 | v2 | Raw pointer flows to initialize multiple unrelated smart pointers. |
69
| test.cpp:12:28:12:29 | v2 | test.cpp:10:8:10:17 | new | test.cpp:12:28:12:29 | v2 | Raw pointer flows to initialize multiple unrelated smart pointers. |
710
| test.cpp:17:27:17:28 | v1 | test.cpp:16:13:16:22 | new | test.cpp:17:27:17:28 | v1 | Raw pointer flows to initialize multiple unrelated smart pointers. |
811
edges
12+
| test.cpp:3:14:3:15 | v1 | test.cpp:4:13:4:14 | v1 | provenance | |
913
| test.cpp:3:14:3:15 | v1 | test.cpp:5:27:5:28 | v1 | provenance | |
1014
| test.cpp:3:14:3:15 | v1 | test.cpp:5:27:5:28 | v1 | provenance | |
11-
| test.cpp:3:14:3:15 | v1 | test.cpp:7:28:7:29 | v2 | provenance | |
15+
| test.cpp:4:13:4:14 | v1 | test.cpp:4:13:4:14 | v1 | provenance | |
16+
| test.cpp:4:13:4:14 | v1 | test.cpp:5:27:5:28 | v1 | provenance | |
17+
| test.cpp:4:13:4:14 | v1 | test.cpp:5:27:5:28 | v1 | provenance | |
1218
| test.cpp:4:13:4:14 | v1 | test.cpp:7:28:7:29 | v2 | provenance | |
13-
| test.cpp:5:27:5:28 | v1 | test.cpp:5:27:5:29 | call to shared_ptr | provenance | |
14-
| test.cpp:5:27:5:28 | v1 | test.cpp:5:27:5:29 | call to shared_ptr | provenance | Config |
15-
| test.cpp:5:27:5:29 | call to shared_ptr | test.cpp:6:28:6:29 | p1 | provenance | |
16-
| test.cpp:5:27:5:29 | call to shared_ptr | test.cpp:6:28:6:29 | p1 | provenance | |
19+
| test.cpp:4:13:4:14 | v1 | test.cpp:7:28:7:29 | v2 | provenance | |
20+
| test.cpp:5:24:5:25 | call to shared_ptr | test.cpp:6:28:6:29 | p1 | provenance | |
21+
| test.cpp:5:24:5:25 | call to shared_ptr | test.cpp:6:28:6:29 | p1 | provenance | |
22+
| test.cpp:5:27:5:28 | v1 | test.cpp:5:24:5:25 | call to shared_ptr | provenance | Config |
23+
| test.cpp:5:27:5:28 | v1 | test.cpp:5:24:5:25 | call to shared_ptr | provenance | Config |
1724
| test.cpp:6:28:6:29 | p1 | test.cpp:6:31:6:33 | call to get | provenance | Config |
1825
| test.cpp:6:28:6:29 | p1 | test.cpp:6:31:6:33 | call to get | provenance | Config |
19-
| test.cpp:8:8:8:14 | 0 | test.cpp:9:28:9:29 | v2 | provenance | |
20-
| test.cpp:10:8:10:17 | new | test.cpp:11:28:11:29 | v2 | provenance | |
21-
| test.cpp:10:8:10:17 | new | test.cpp:12:28:12:29 | v2 | provenance | |
26+
| test.cpp:8:3:8:14 | ... = ... | test.cpp:9:28:9:29 | v2 | provenance | |
27+
| test.cpp:8:8:8:14 | 0 | test.cpp:8:3:8:14 | ... = ... | provenance | |
28+
| test.cpp:10:3:10:17 | ... = ... | test.cpp:11:28:11:29 | v2 | provenance | |
29+
| test.cpp:10:3:10:17 | ... = ... | test.cpp:11:28:11:29 | v2 | provenance | |
30+
| test.cpp:10:8:10:17 | new | test.cpp:10:3:10:17 | ... = ... | provenance | |
31+
| test.cpp:11:28:11:29 | v2 | test.cpp:12:28:12:29 | v2 | provenance | |
32+
| test.cpp:16:13:16:22 | new | test.cpp:16:13:16:22 | new | provenance | |
33+
| test.cpp:16:13:16:22 | new | test.cpp:17:27:17:28 | v1 | provenance | |
2234
| test.cpp:16:13:16:22 | new | test.cpp:17:27:17:28 | v1 | provenance | |
23-
| test.cpp:16:13:16:22 | new | test.cpp:19:6:19:7 | v1 | provenance | |
35+
| test.cpp:17:27:17:28 | v1 | test.cpp:19:6:19:7 | v1 | provenance | |
2436
| test.cpp:19:6:19:7 | v1 | test.cpp:3:14:3:15 | v1 | provenance | |
2537
nodes
2638
| test.cpp:3:14:3:15 | v1 | semmle.label | v1 |
2739
| test.cpp:4:13:4:14 | v1 | semmle.label | v1 |
40+
| test.cpp:4:13:4:14 | v1 | semmle.label | v1 |
41+
| test.cpp:4:13:4:14 | v1 | semmle.label | v1 |
42+
| test.cpp:5:24:5:25 | call to shared_ptr | semmle.label | call to shared_ptr |
43+
| test.cpp:5:24:5:25 | call to shared_ptr | semmle.label | call to shared_ptr |
44+
| test.cpp:5:27:5:28 | v1 | semmle.label | v1 |
2845
| test.cpp:5:27:5:28 | v1 | semmle.label | v1 |
2946
| test.cpp:5:27:5:28 | v1 | semmle.label | v1 |
30-
| test.cpp:5:27:5:29 | call to shared_ptr | semmle.label | call to shared_ptr |
31-
| test.cpp:5:27:5:29 | call to shared_ptr | semmle.label | call to shared_ptr |
3247
| test.cpp:6:28:6:29 | p1 | semmle.label | p1 |
3348
| test.cpp:6:28:6:29 | p1 | semmle.label | p1 |
3449
| test.cpp:6:31:6:33 | call to get | semmle.label | call to get |
3550
| test.cpp:7:28:7:29 | v2 | semmle.label | v2 |
51+
| test.cpp:8:3:8:14 | ... = ... | semmle.label | ... = ... |
3652
| test.cpp:8:8:8:14 | 0 | semmle.label | 0 |
3753
| test.cpp:9:28:9:29 | v2 | semmle.label | v2 |
54+
| test.cpp:10:3:10:17 | ... = ... | semmle.label | ... = ... |
3855
| test.cpp:10:8:10:17 | new | semmle.label | new |
3956
| test.cpp:11:28:11:29 | v2 | semmle.label | v2 |
57+
| test.cpp:11:28:11:29 | v2 | semmle.label | v2 |
4058
| test.cpp:12:28:12:29 | v2 | semmle.label | v2 |
4159
| test.cpp:16:13:16:22 | new | semmle.label | new |
60+
| test.cpp:16:13:16:22 | new | semmle.label | new |
61+
| test.cpp:17:27:17:28 | v1 | semmle.label | v1 |
4262
| test.cpp:17:27:17:28 | v1 | semmle.label | v1 |
4363
| test.cpp:19:6:19:7 | v1 | semmle.label | v1 |
4464
subpaths

0 commit comments

Comments
 (0)