File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed
cpp/ql/src/semmle/code/cpp/commons Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -48,6 +48,7 @@ predicate memberMayBeVarSize(Class c, MemberVariable v) {
4848/**
4949 * Get the size in bytes of the buffer pointed to by an expression (if this can be determined).
5050 */
51+ language [ monotonicAggregates]
5152int getBufferSize ( Expr bufferExpr , Element why ) {
5253 exists ( Variable bufferVar | bufferVar = bufferExpr .( VariableAccess ) .getTarget ( ) |
5354 (
@@ -82,16 +83,19 @@ int getBufferSize(Expr bufferExpr, Element why) {
8283 why = bufferExpr
8384 ) or (
8485 // dataflow (all sources must be the same size)
85- forex ( Expr def |
86+ result = min ( Expr def |
8687 DataFlow:: localFlowStep ( DataFlow:: exprNode ( def ) , DataFlow:: exprNode ( bufferExpr ) ) |
87- result = getBufferSize ( def , _)
88+ getBufferSize ( def , _)
89+ ) and result = max ( Expr def |
90+ DataFlow:: localFlowStep ( DataFlow:: exprNode ( def ) , DataFlow:: exprNode ( bufferExpr ) ) |
91+ getBufferSize ( def , _)
8892 ) and
8993
9094 // find reason
9195 exists ( Expr def |
9296 DataFlow:: localFlowStep ( DataFlow:: exprNode ( def ) , DataFlow:: exprNode ( bufferExpr ) ) |
9397 why = def or
94- result = getBufferSize ( def , why )
98+ exists ( getBufferSize ( def , why ) )
9599 )
96100 ) or exists ( Type bufferType |
97101 // buffer is the address of a variable
You can’t perform that action at this time.
0 commit comments