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) {
382
382
result = f .log10 ( ) .floor ( ) + 1
383
383
}
384
384
385
+ pragma [ nomagic]
386
+ private predicate isPointerTypeWithBase ( Type base , PointerType pt ) { base = pt .getBaseType ( ) }
387
+
385
388
bindingset [ expr]
386
389
private BufferWriteEstimationReason getEstimationReasonForIntegralExpression ( Expr expr ) {
387
390
// we consider the range analysis non trivial if it
@@ -962,19 +965,19 @@ class FormatLiteral extends Literal {
962
965
(
963
966
conv = [ "s" , "S" ] and
964
967
len = "h" and
965
- result . ( PointerType ) . getBaseType ( ) instanceof PlainCharType
968
+ isPointerTypeWithBase ( any ( PlainCharType plainCharType ) , result )
966
969
or
967
970
conv = [ "s" , "S" ] and
968
971
len = [ "l" , "w" ] and
969
- result . ( PointerType ) . getBaseType ( ) = this .getWideCharType ( )
972
+ isPointerTypeWithBase ( this .getWideCharType ( ) , result )
970
973
or
971
974
conv = "s" and
972
975
( len != "l" and len != "w" and len != "h" ) and
973
- result . ( PointerType ) . getBaseType ( ) = this .getDefaultCharType ( )
976
+ isPointerTypeWithBase ( this .getDefaultCharType ( ) , result )
974
977
or
975
978
conv = "S" and
976
979
( len != "l" and len != "w" and len != "h" ) and
977
- result . ( PointerType ) . getBaseType ( ) = this .getNonDefaultCharType ( )
980
+ isPointerTypeWithBase ( this .getNonDefaultCharType ( ) , result )
978
981
)
979
982
)
980
983
}
You can’t perform that action at this time.
0 commit comments