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) {
359359 result = f .log10 ( ) .floor ( ) + 1
360360}
361361
362+ pragma [ nomagic]
363+ private predicate isPointerTypeWithBase ( Type base , PointerType pt ) { base = pt .getBaseType ( ) }
364+
362365/**
363366 * A class to represent format strings that occur as arguments to invocations of formatting functions.
364367 */
@@ -910,19 +913,19 @@ class FormatLiteral extends Literal {
910913 (
911914 conv = [ "s" , "S" ] and
912915 len = "h" and
913- result . ( PointerType ) . getBaseType ( ) instanceof PlainCharType
916+ isPointerTypeWithBase ( any ( PlainCharType plainCharType ) , result )
914917 or
915918 conv = [ "s" , "S" ] and
916919 len = [ "l" , "w" ] and
917- result . ( PointerType ) . getBaseType ( ) = this .getWideCharType ( )
920+ isPointerTypeWithBase ( this .getWideCharType ( ) , result )
918921 or
919922 conv = "s" and
920923 ( len != "l" and len != "w" and len != "h" ) and
921- result . ( PointerType ) . getBaseType ( ) = this .getDefaultCharType ( )
924+ isPointerTypeWithBase ( this .getDefaultCharType ( ) , result )
922925 or
923926 conv = "S" and
924927 ( len != "l" and len != "w" and len != "h" ) and
925- result . ( PointerType ) . getBaseType ( ) = this .getNonDefaultCharType ( )
928+ isPointerTypeWithBase ( this .getNonDefaultCharType ( ) , result )
926929 )
927930 )
928931 }
You can’t perform that action at this time.
0 commit comments