Skip to content

Commit b86bd5f

Browse files
committed
STR53-CPP: add string constructor
1 parent 0a7abd6 commit b86bd5f

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

cpp/common/src/codingstandards/cpp/rules/containeraccesswithoutrangecheck/ContainerAccessWithoutRangeCheck.qll

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -179,17 +179,27 @@ class StringContainerConstructorCall extends ContainerConstructorCall {
179179
c.getNumberOfParameters() = 0 and
180180
result = 0
181181
or
182-
// from c-string constructor
183-
c.getNumberOfParameters() = 2 and
182+
// from c-string constructors
183+
c.getNumberOfParameters() = 1 and
184184
c.getParameter(0).getType() = stringInstantiation.getValueType() and
185-
c.getParameter(1).getType() = stringInstantiation.getConstAllocatorReferenceType() and
186185
result = getArgument(0).getValue().length()
187186
or
188-
// from c-string copy constructor
189-
c.getNumberOfParameters() = 1 and
187+
c.getNumberOfParameters() = 2 and
190188
c.getParameter(0).getType() = stringInstantiation.getValueType() and
189+
c.getParameter(1).getType() = stringInstantiation.getSizeType() and
190+
result = getArgument(1).getValue().toFloat()
191+
or
192+
c.getNumberOfParameters() = 2 and
193+
c.getParameter(0).getType() = stringInstantiation.getSizeType() and
194+
c.getParameter(1).getType() = stringInstantiation.getCharT() and
195+
result = getArgument(0).getValue().toFloat()
196+
or
197+
c.getNumberOfParameters() = 2 and
198+
c.getParameter(0).getType() = stringInstantiation.getValueType() and
199+
c.getParameter(1).getType() = stringInstantiation.getConstAllocatorReferenceType() and
191200
result = getArgument(0).getValue().length()
192201
or
202+
193203
// Lower bound of an explicit size argument
194204
result = lowerBound(getInitialContainerSizeExpr().getFullyConverted())
195205
}

0 commit comments

Comments
 (0)