Skip to content

Commit 79ff559

Browse files
geoffw0Robert Marsh
authored andcommitted
CPP: Don't require alloc in memberMayBeVarSize.
1 parent 19a53cd commit 79ff559

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,12 @@ predicate memberMayBeVarSize(Class c, MemberVariable v) {
3333
// `sizeof(c)` is taken
3434
so.(SizeofTypeOperator).getTypeOperand().getUnspecifiedType() = c or
3535
so.(SizeofExprOperator).getExprOperand().getType().getUnspecifiedType() = c |
36-
// Check all ancestor nodes except the immediate parent for
37-
// allocations.
38-
isStdLibAllocationExpr(so.getParent().(Expr).getParent+())
36+
37+
// arithmetic is performed on the result
38+
so.getParent*() instanceof BinaryArithmeticOperation
3939
) or exists(AddressOfExpr aoe |
4040
// `&(c.v)` is taken
41-
aoe.getAddressable() = v and
42-
isStdLibAllocationExpr(aoe.getParent().(Expr).getParent+())
41+
aoe.getAddressable() = v
4342
)
4443
)
4544
}

0 commit comments

Comments
 (0)