mirror of
https://github.com/github/codeql.git
synced 2026-04-26 09:15:12 +02:00
add support for try-statements with no catch block
This commit is contained in:
@@ -251,11 +251,11 @@ class Expr extends @expr, ExprOrStmt, ExprOrType, AST::ValueNode {
|
||||
* causes an exception to be thrown.
|
||||
*/
|
||||
DataFlow::Node getThrowsToNode() {
|
||||
if exists(this.getEnclosingStmt().getEnclosingTryStmt())
|
||||
if exists(this.getEnclosingStmt().getEnclosingTryCatchStmt())
|
||||
then
|
||||
result = DataFlow::parameterNode(this
|
||||
.getEnclosingStmt()
|
||||
.getEnclosingTryStmt()
|
||||
.getEnclosingTryCatchStmt()
|
||||
.getACatchClause()
|
||||
.getAParameter())
|
||||
else result = any(DataFlow::FunctionNode f | f.getFunction() = this.getContainer()).getExceptionalReturn()
|
||||
|
||||
@@ -57,12 +57,13 @@ class Stmt extends @stmt, ExprOrStmt, Documentable {
|
||||
override predicate isAmbient() { hasDeclareKeyword(this) or getParent().isAmbient() }
|
||||
|
||||
/**
|
||||
* Gets the `try` statement containing this statement without crossing function
|
||||
* boundaries or other `try ` statements.
|
||||
* Gets the `try` statement with a catch block containing this statement without
|
||||
* crossing function boundaries or other `try ` statements with catch blocks.
|
||||
*/
|
||||
TryStmt getEnclosingTryStmt() {
|
||||
TryStmt getEnclosingTryCatchStmt() {
|
||||
getParentStmt+() = result.getBody() and
|
||||
not exists(TryStmt mid |
|
||||
exists(result.getACatchClause()) and
|
||||
not exists(TryStmt mid | exists(mid.getACatchClause()) |
|
||||
getParentStmt+() = mid.getBody() and mid.getParentStmt+() = result.getBody()
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user