diff --git a/cpp/ql/lib/semmle/code/cpp/commons/Buffer.qll b/cpp/ql/lib/semmle/code/cpp/commons/Buffer.qll index df2d04a97d7b..70d6795f76b0 100644 --- a/cpp/ql/lib/semmle/code/cpp/commons/Buffer.qll +++ b/cpp/ql/lib/semmle/code/cpp/commons/Buffer.qll @@ -49,7 +49,11 @@ private Class getRootType(FieldAccess fa) { exists(VariableAccess root | root = fa.getQualifier+() and not exists(root.getQualifier()) and - result = root.getUnspecifiedType() + // We strip the type because the root may be a pointer. For example `p` in: + // struct S { char buffer[10]; }; + // S* p = ...; + // strcpy(p->buffer, "abc"); + result = root.getUnspecifiedType().stripType() ) }