File tree Expand file tree Collapse file tree 1 file changed +7
-4
lines changed
cpp/ql/lib/semmle/code/cpp/commons Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -359,6 +359,9 @@ private int lengthInBase10(float f) {
359
359
result = f .log10 ( ) .floor ( ) + 1
360
360
}
361
361
362
+ pragma [ nomagic]
363
+ private predicate isPointerTypeWithBase ( Type base , PointerType pt ) { base = pt .getBaseType ( ) }
364
+
362
365
/**
363
366
* A class to represent format strings that occur as arguments to invocations of formatting functions.
364
367
*/
@@ -910,19 +913,19 @@ class FormatLiteral extends Literal {
910
913
(
911
914
conv = [ "s" , "S" ] and
912
915
len = "h" and
913
- result . ( PointerType ) . getBaseType ( ) instanceof PlainCharType
916
+ isPointerTypeWithBase ( any ( PlainCharType plainCharType ) , result )
914
917
or
915
918
conv = [ "s" , "S" ] and
916
919
len = [ "l" , "w" ] and
917
- result . ( PointerType ) . getBaseType ( ) = this .getWideCharType ( )
920
+ isPointerTypeWithBase ( this .getWideCharType ( ) , result )
918
921
or
919
922
conv = "s" and
920
923
( len != "l" and len != "w" and len != "h" ) and
921
- result . ( PointerType ) . getBaseType ( ) = this .getDefaultCharType ( )
924
+ isPointerTypeWithBase ( this .getDefaultCharType ( ) , result )
922
925
or
923
926
conv = "S" and
924
927
( len != "l" and len != "w" and len != "h" ) and
925
- result . ( PointerType ) . getBaseType ( ) = this .getNonDefaultCharType ( )
928
+ isPointerTypeWithBase ( this .getNonDefaultCharType ( ) , result )
926
929
)
927
930
)
928
931
}
You can’t perform that action at this time.
0 commit comments