Skip to content

Commit ec205e9

Browse files
committed
CPP: Include sizeof(expr) expressions in isDynamicallyAllocatedWithDifferentSize.
1 parent 976e5ed commit ec205e9

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

cpp/ql/src/semmle/code/cpp/commons/Buffer.qll

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,12 @@ import semmle.code.cpp.dataflow.DataFlow
1616
* ```
1717
*/
1818
private predicate isDynamicallyAllocatedWithDifferentSize(Class s) {
19-
exists(SizeofTypeOperator sof |
20-
sof.getTypeOperand().getUnspecifiedType() = s |
19+
exists(SizeofOperator so |
20+
so.(SizeofTypeOperator).getTypeOperand().getUnspecifiedType() = s or
21+
so.(SizeofExprOperator).getExprOperand().getType().getUnspecifiedType() = s |
2122
// Check all ancestor nodes except the immediate parent for
2223
// allocations.
23-
isStdLibAllocationExpr(sof.getParent().(Expr).getParent+())
24+
isStdLibAllocationExpr(so.getParent().(Expr).getParent+())
2425
)
2526
}
2627

0 commit comments

Comments
 (0)