Skip to content

Commit 91752e5

Browse files
committed
C++: Enforce uniqueness in 'getVariableSize'.
1 parent 2bd4cce commit 91752e5

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,13 @@ private Class getRootType(FieldAccess fa) {
6262
* unspecified type of `v` is a `ReferenceType`.
6363
*/
6464
private int getVariableSize(Variable v) {
65-
exists(Type t |
66-
t = v.getUnspecifiedType() and
67-
not t instanceof ReferenceType and
68-
result = t.getSize()
69-
)
65+
result =
66+
unique(Type t |
67+
t = v.getUnspecifiedType() and
68+
not t instanceof ReferenceType
69+
|
70+
t.getSize()
71+
)
7072
}
7173

7274
/**

0 commit comments

Comments
 (0)