File tree Expand file tree Collapse file tree
cpp/ql/src/semmle/code/cpp/models/implementations Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -30,10 +30,19 @@ class StdStringConstructor extends Constructor, TaintFunction {
3030 * character).
3131 */
3232 int getAStringParameterIndex ( ) {
33- getParameter ( result ) .getType ( ) instanceof PointerType or // e.g. `std::basic_string::CharT *`
34- getParameter ( result ) .getType ( ) instanceof ReferenceType or // e.g. `std::basic_string &`
35- getParameter ( result ) .getUnspecifiedType ( ) =
36- getDeclaringType ( ) .getTemplateArgument ( 0 ) .( Type ) .getUnspecifiedType ( ) // i.e. `std::basic_string::CharT`
33+ exists ( Type paramType | paramType = getParameter ( result ) .getUnspecifiedType ( ) |
34+ // e.g. `std::basic_string::CharT *`
35+ paramType instanceof PointerType
36+ or
37+ // e.g. `std::basic_string &`, avoiding `const Allocator&`
38+ paramType instanceof ReferenceType and
39+ not paramType .( ReferenceType ) .getBaseType ( ) =
40+ getDeclaringType ( ) .getTemplateArgument ( 2 ) .( Type ) .getUnspecifiedType ( )
41+ or
42+ // i.e. `std::basic_string::CharT`
43+ getParameter ( result ) .getUnspecifiedType ( ) =
44+ getDeclaringType ( ) .getTemplateArgument ( 0 ) .( Type ) .getUnspecifiedType ( )
45+ )
3746 }
3847
3948 /**
You can’t perform that action at this time.
0 commit comments