File tree Expand file tree Collapse file tree 1 file changed +6
-3
lines changed
cpp/ql/lib/semmle/code/cpp/commons Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -73,6 +73,10 @@ private int isSource(Expr bufferExpr, Element why) {
7373 )
7474}
7575
76+ /** Same as `getBufferSize`, but with the `why` column projected away to prevent large duplications. */
77+ pragma [ nomagic]
78+ int getBufferSizeProj ( Expr bufferExpr ) { result = getBufferSize ( bufferExpr , _) }
79+
7680/**
7781 * Get the size in bytes of the buffer pointed to by an expression (if this can be determined).
7882 */
@@ -87,15 +91,14 @@ int getBufferSize(Expr bufferExpr, Element why) {
8791 why = bufferVar and
8892 parentPtr = bufferExpr .( VariableAccess ) .getQualifier ( ) and
8993 parentPtr .getTarget ( ) .getUnspecifiedType ( ) .( PointerType ) .getBaseType ( ) = parentClass and
90- result = getBufferSize ( parentPtr , _ ) + bufferSize - parentClass .getSize ( )
94+ result = getBufferSizeProj ( parentPtr ) + bufferSize - parentClass .getSize ( )
9195 |
9296 if exists ( bufferVar .getType ( ) .getSize ( ) )
9397 then bufferSize = bufferVar .getType ( ) .getSize ( )
9498 else bufferSize = 0
9599 )
96100 or
97101 // dataflow (all sources must be the same size)
98- result = unique( Expr def | DataFlow:: localExprFlowStep ( def , bufferExpr ) | getBufferSize ( def , _) ) and
99- // find reason
102+ result = unique( Expr def | DataFlow:: localExprFlowStep ( def , bufferExpr ) | getBufferSizeProj ( def ) ) and
100103 exists ( Expr def | DataFlow:: localExprFlowStep ( def , bufferExpr ) | exists ( getBufferSize ( def , why ) ) )
101104}
You can’t perform that action at this time.
0 commit comments