Merge pull request #1141 from geoffw0/newfreebug

CPP: Fix a bug in NewFree.qll
This commit is contained in:
Jonas Jensen
2019-03-21 17:22:00 +01:00
committed by GitHub
3 changed files with 74 additions and 1 deletions

View File

@@ -3,6 +3,7 @@
*/
import cpp
import semmle.code.cpp.controlflow.SSA
import semmle.code.cpp.dataflow.DataFlow
/**
* Holds if `alloc` is a use of `malloc` or `new`. `kind` is
@@ -46,7 +47,10 @@ predicate allocExprOrIndirect(Expr alloc, string kind) {
alloc.(FunctionCall).getTarget() = rtn.getEnclosingFunction() and
(
allocExprOrIndirect(rtn.getExpr(), kind) or
allocReaches0(rtn.getExpr(), _, kind)
exists(Expr e |
allocExprOrIndirect(e, kind) and
DataFlow::localFlow(DataFlow::exprNode(e), DataFlow::exprNode(rtn.getExpr()))
)
)
)
}