CPP: Include sizeof(expr) expressions in isDynamicallyAllocatedWithDifferentSize.

This commit is contained in:
Geoffrey White
2018-10-24 15:52:29 +01:00
parent 976e5ed80f
commit ec205e995b

View File

@@ -16,11 +16,12 @@ import semmle.code.cpp.dataflow.DataFlow
* ```
*/
private predicate isDynamicallyAllocatedWithDifferentSize(Class s) {
exists(SizeofTypeOperator sof |
sof.getTypeOperand().getUnspecifiedType() = s |
exists(SizeofOperator so |
so.(SizeofTypeOperator).getTypeOperand().getUnspecifiedType() = s or
so.(SizeofExprOperator).getExprOperand().getType().getUnspecifiedType() = s |
// Check all ancestor nodes except the immediate parent for
// allocations.
isStdLibAllocationExpr(sof.getParent().(Expr).getParent+())
isStdLibAllocationExpr(so.getParent().(Expr).getParent+())
)
}