From 91752e5307c03248c4eec1e712b1526c2305f5d4 Mon Sep 17 00:00:00 2001 From: Mathias Vorreiter Pedersen Date: Mon, 26 Jan 2026 15:00:00 +0000 Subject: [PATCH] C++: Enforce uniqueness in 'getVariableSize'. --- cpp/ql/lib/semmle/code/cpp/commons/Buffer.qll | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/cpp/ql/lib/semmle/code/cpp/commons/Buffer.qll b/cpp/ql/lib/semmle/code/cpp/commons/Buffer.qll index 675090ad958..5dfeb8f3137 100644 --- a/cpp/ql/lib/semmle/code/cpp/commons/Buffer.qll +++ b/cpp/ql/lib/semmle/code/cpp/commons/Buffer.qll @@ -62,11 +62,13 @@ private Class getRootType(FieldAccess fa) { * unspecified type of `v` is a `ReferenceType`. */ private int getVariableSize(Variable v) { - exists(Type t | - t = v.getUnspecifiedType() and - not t instanceof ReferenceType and - result = t.getSize() - ) + result = + unique(Type t | + t = v.getUnspecifiedType() and + not t instanceof ReferenceType + | + t.getSize() + ) } /**