Skip to content

Commit c179a07

Browse files
author
Robert Marsh
committed
C++: fix constructor models
1 parent 3a83cc7 commit c179a07

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

cpp/ql/src/semmle/code/cpp/models/implementations/StdContainer.qll

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,11 @@ class StdSequenceContainerConstructor extends Constructor, TaintFunction {
3838
input.isParameterDeref(getAValueTypeParameterIndex()) or
3939
input.isParameter(getAnIteratorParameterIndex())
4040
) and
41-
output.isReturnValue()
42-
or
43-
output.isQualifierObject()
41+
(
42+
output.isReturnValue() // TODO: this is only needed for AST data flow, which treats constructors as returning the new object
43+
or
44+
output.isQualifierObject()
45+
)
4446
}
4547
}
4648

cpp/ql/src/semmle/code/cpp/models/implementations/StdString.qll

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class StdStringConstructor extends Constructor, TaintFunction {
4848
input.isParameter(getAnIteratorParameterIndex())
4949
) and
5050
(
51-
output.isReturnValue()
51+
output.isReturnValue() // TODO: this is only needed for AST data flow, which treats constructors as returning the new object
5252
or
5353
output.isQualifierObject()
5454
)
@@ -383,9 +383,11 @@ class StdStringStreamConstructor extends Constructor, TaintFunction {
383383
override predicate hasTaintFlow(FunctionInput input, FunctionOutput output) {
384384
// taint flow from any parameter of string type to the returned object
385385
input.isParameterDeref(getAStringParameterIndex()) and
386-
output.isReturnValue()
387-
or
388-
output.isQualifierObject()
386+
(
387+
output.isReturnValue() // TODO: this is only needed for AST data flow, which treats constructors as returning the new object
388+
or
389+
output.isQualifierObject()
390+
)
389391
}
390392
}
391393

0 commit comments

Comments
 (0)