C++: Fix join in 'cpp/upcast-array-pointer-arithmetic'.

This commit is contained in:
Mathias Vorreiter Pedersen
2022-11-18 10:19:55 +00:00
parent f1b85d7ebf
commit 1e14af6e64

View File

@@ -64,10 +64,15 @@ predicate introducesNewField(Class derived, Class base) {
)
}
from DataFlow::PathNode source, DataFlow::PathNode sink, CastToPointerArithFlow cfg
pragma[nomagic]
predicate hasFullyConvertedType(DataFlow::PathNode node, Type t) {
t = node.getNode().asExpr().getFullyConverted().getUnspecifiedType()
}
from DataFlow::PathNode source, DataFlow::PathNode sink, CastToPointerArithFlow cfg, Type t
where
cfg.hasFlowPath(source, sink) and
source.getNode().asExpr().getFullyConverted().getUnspecifiedType() =
sink.getNode().asExpr().getFullyConverted().getUnspecifiedType()
cfg.hasFlowPath(pragma[only_bind_into](source), pragma[only_bind_into](sink)) and
hasFullyConvertedType(source, t) and
hasFullyConvertedType(sink, t)
select sink, source, sink, "This pointer arithmetic may be done with the wrong type because of $@.",
source, "this cast"