Skip to content

Commit 5e92763

Browse files
authored
Merge pull request #18660 from MathiasVP/fix-union-regression
C++: Fix regression from #18629
2 parents 0584aee + 0e6936d commit 5e92763

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,11 @@ private Class getRootType(FieldAccess fa) {
4949
exists(VariableAccess root |
5050
root = fa.getQualifier+() and
5151
not exists(root.getQualifier()) and
52-
result = root.getUnspecifiedType()
52+
// We strip the type because the root may be a pointer. For example `p` in:
53+
// struct S { char buffer[10]; };
54+
// S* p = ...;
55+
// strcpy(p->buffer, "abc");
56+
result = root.getUnspecifiedType().stripType()
5357
)
5458
}
5559

0 commit comments

Comments
 (0)