File tree Expand file tree Collapse file tree
cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -103,10 +103,18 @@ private class PointerOrArrayOrReferenceType extends Cpp::DerivedType {
103103 * (i.e., `countIndirections(e.getUnspecifiedType())`).
104104 */
105105private 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+ )
110118}
111119
112120/**
You can’t perform that action at this time.
0 commit comments