File tree Expand file tree Collapse file tree 1 file changed +12
-4
lines changed
cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -103,10 +103,18 @@ private class PointerOrArrayOrReferenceType extends Cpp::DerivedType {
103
103
* (i.e., `countIndirections(e.getUnspecifiedType())`).
104
104
*/
105
105
private int countIndirections ( Type t ) {
106
- result = any ( Indirection ind | ind .getType ( ) = t ) .getNumberOfIndirections ( )
107
- or
108
- not exists ( Indirection ind | ind .getType ( ) = t ) and
109
- result = 0
106
+ // We special case void pointers because we don't know how many indirections
107
+ // they really have. In a Glorious Future we could do a pre-analysis to figure out
108
+ // which kinds of values flows into the type and use the maximum number of
109
+ // indirections flowinginto the type.
110
+ if t instanceof Cpp:: VoidPointerType
111
+ then result = 2
112
+ else (
113
+ result = any ( Indirection ind | ind .getType ( ) = t ) .getNumberOfIndirections ( )
114
+ or
115
+ not exists ( Indirection ind | ind .getType ( ) = t ) and
116
+ result = 0
117
+ )
110
118
}
111
119
112
120
/**
You can’t perform that action at this time.
0 commit comments