Skip to content

Commit 313624f

Browse files
geoffw0Robert Marsh
authored andcommitted
CPP: Support builtin offsetof.
1 parent 79ff559 commit 313624f

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ predicate memberMayBeVarSize(Class c, MemberVariable v) {
3939
) or exists(AddressOfExpr aoe |
4040
// `&(c.v)` is taken
4141
aoe.getAddressable() = v
42+
) or exists(BuiltInOperationOffsetOf oo |
43+
// `offsetof(c, v)` using a builtin
44+
oo.getAChild().(VariableAccess).getTarget() = v
4245
)
4346
)
4447
}

0 commit comments

Comments
 (0)