File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed
cpp/ql/src/experimental/Security/CWE/CWE-416 Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -37,6 +37,11 @@ module TempToDestructorConfig implements DataFlow::ConfigSig {
37
37
38
38
module TempToDestructorFlow = DataFlow:: Global< TempToDestructorConfig > ;
39
39
40
+ /** Holds if `pun` is the post-update node of the qualifier of `Call`. */
41
+ private predicate isPostUpdateOfQualifier ( CallInstruction call , DataFlow:: PostUpdateNode pun ) {
42
+ call .getThisArgumentOperand ( ) = pun .getPreUpdateNode ( ) .asOperand ( )
43
+ }
44
+
40
45
/**
41
46
* Gets a `DataFlow::Node` that represents a temporary that will be destroyed
42
47
* by a call to a destructor, or a `DataFlow::Node` that will transitively be
@@ -53,8 +58,12 @@ module TempToDestructorFlow = DataFlow::Global<TempToDestructorConfig>;
53
58
* and thus the result of `get_2d_vector()[0]` is also an invalid reference.
54
59
*/
55
60
DataFlow:: Node getADestroyedNode ( ) {
56
- exists ( TempToDestructorFlow:: PathNode destroyedTemp | destroyedTemp .isSource ( ) |
57
- result = destroyedTemp .getNode ( )
61
+ exists ( DataFlow:: Node n | TempToDestructorFlow:: flowTo ( n ) |
62
+ // Case 1: The pointer that goes into the destructor call is destroyed
63
+ exists ( CallInstruction destructorCall |
64
+ tempToDestructorSink ( n , destructorCall ) and
65
+ isPostUpdateOfQualifier ( destructorCall , result )
66
+ )
58
67
or
59
68
exists ( CallInstruction call |
60
69
result .asInstruction ( ) = call and
You can’t perform that action at this time.
0 commit comments