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 @@ -382,6 +382,9 @@ private int lengthInBase10(float f) {
382382 result = f .log10 ( ) .floor ( ) + 1
383383}
384384
385+ pragma [ nomagic]
386+ private predicate isPointerTypeWithBase ( Type base , PointerType pt ) { base = pt .getBaseType ( ) }
387+
385388bindingset [ expr]
386389private BufferWriteEstimationReason getEstimationReasonForIntegralExpression ( Expr expr ) {
387390 // we consider the range analysis non trivial if it
@@ -962,19 +965,19 @@ class FormatLiteral extends Literal {
962965 (
963966 conv = [ "s" , "S" ] and
964967 len = "h" and
965- result . ( PointerType ) . getBaseType ( ) instanceof PlainCharType
968+ isPointerTypeWithBase ( any ( PlainCharType plainCharType ) , result )
966969 or
967970 conv = [ "s" , "S" ] and
968971 len = [ "l" , "w" ] and
969- result . ( PointerType ) . getBaseType ( ) = this .getWideCharType ( )
972+ isPointerTypeWithBase ( this .getWideCharType ( ) , result )
970973 or
971974 conv = "s" and
972975 ( len != "l" and len != "w" and len != "h" ) and
973- result . ( PointerType ) . getBaseType ( ) = this .getDefaultCharType ( )
976+ isPointerTypeWithBase ( this .getDefaultCharType ( ) , result )
974977 or
975978 conv = "S" and
976979 ( len != "l" and len != "w" and len != "h" ) and
977- result . ( PointerType ) . getBaseType ( ) = this .getNonDefaultCharType ( )
980+ isPointerTypeWithBase ( this .getNonDefaultCharType ( ) , result )
978981 )
979982 )
980983 }
You can’t perform that action at this time.
0 commit comments