Skip to content

Commit 580471a

Browse files
committed
CPP: Replace stripTopLevelSpecifiers to emulate old behaviour.
1 parent 89c5648 commit 580471a

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

cpp/ql/src/semmle/code/cpp/models/interfaces/FormattingFunction.qll

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,15 @@ private Type getAFormatterWideTypeOrDefault() {
1919
)
2020
}
2121

22+
private Type stripTopLevelSpecifiersOnly(Type t) {
23+
(
24+
result = stripTopLevelSpecifiersOnly(t.(SpecifiedType).getBaseType())
25+
) or (
26+
result = t and
27+
not t instanceof SpecifiedType
28+
)
29+
}
30+
2231
/**
2332
* A standard library function that uses a `printf`-like formatting string.
2433
*/
@@ -37,8 +46,8 @@ abstract class FormattingFunction extends Function {
3746
* `char` or `wchar_t`.
3847
*/
3948
Type getDefaultCharType() {
40-
result = getParameter(getFormatParameterIndex()).getType().
41-
getUnderlyingType().(PointerType).getBaseType().stripTopLevelSpecifiers()
49+
result = stripTopLevelSpecifiersOnly(getParameter(getFormatParameterIndex()).getType().
50+
getUnderlyingType().(PointerType).getBaseType())
4251
}
4352

4453
/**

0 commit comments

Comments
 (0)