|
15 | 15 | */ |
16 | 16 |
|
17 | 17 | import cpp |
18 | | -import semmle.code.cpp.dataflow.DataFlow |
| 18 | +import semmle.code.cpp.dataflow.new.DataFlow |
19 | 19 | import codingstandards.cpp.autosar |
20 | 20 | import codingstandards.cpp.exceptions.ExceptionFlow |
21 | 21 | import codingstandards.cpp.exceptions.ExceptionSpecifications |
@@ -98,6 +98,18 @@ class ExceptionThrownInConstructor extends ExceptionThrowingExpr { |
98 | 98 | Constructor getConstructor() { result = c } |
99 | 99 | } |
100 | 100 |
|
| 101 | +module NewDeleteConfig implements DataFlow::ConfigSig { |
| 102 | + predicate isSource(DataFlow::Node src) { src.asExpr() instanceof NewAllocationExpr } |
| 103 | + |
| 104 | + predicate isSink(DataFlow::Node sink) { sink.asExpr() instanceof DeletedExpr } |
| 105 | + |
| 106 | + DataFlow::FlowFeature getAFeature() { |
| 107 | + result instanceof DataFlow::FeatureEqualSourceSinkCallContext |
| 108 | + } |
| 109 | +} |
| 110 | + |
| 111 | +module NewDeleteFlow = DataFlow::Global<NewDeleteConfig>; |
| 112 | + |
101 | 113 | from |
102 | 114 | ExceptionThrowingConstructor c, ExceptionThrownInConstructor throwingExpr, |
103 | 115 | NewAllocationExpr newExpr, ExceptionFlowNode exceptionSource, |
@@ -127,7 +139,7 @@ where |
127 | 139 | not exists(DeletedExpr deletedExpr | |
128 | 140 | deletedExpr.getEnclosingFunction() = c and |
129 | 141 | // Deletes the same memory location that was new'd |
130 | | - DataFlow::localFlow(DataFlow::exprNode(newExpr), DataFlow::exprNode(deletedExpr)) and |
| 142 | + NewDeleteFlow::flow(DataFlow::exprNode(newExpr), DataFlow::exprNode(deletedExpr)) and |
131 | 143 | newExpr.getASuccessor+() = deletedExpr and |
132 | 144 | deletedExpr.getASuccessor+() = throwingExpr |
133 | 145 | ) and |
|
0 commit comments