Skip to content

Commit

Permalink
Merge pull request #2133 from MarcMil/fixdex
Browse files Browse the repository at this point in the history
.NET: Fix a problem for empty catch handlers
  • Loading branch information
StevenArzt authored Dec 14, 2024
2 parents 31aed29 + e9dd718 commit a87831d
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,16 +94,19 @@ public Body getFilterHandlerBody(Value generalExceptionVariable) {
ConditionExpr cond = Jimple.v().newEqExpr(returnValue, IntConstant.v(0));
IfStmt ifRetCondStmt = Jimple.v().newIfStmt(cond, filterCondFalseNop); // if ret==0 ignore handler
// jump to end of filter instructions - cond true
GotoStmt gotoHandlerBodyCondTrueStmt = Jimple.v().newGotoStmt(handlerBody.getUnits().getFirst());
if (!handlerBody.getUnits().isEmpty()) {
//this may happen when there is an empty handler
GotoStmt gotoHandlerBodyCondTrueStmt = Jimple.v().newGotoStmt(handlerBody.getUnits().getFirst());

handlerFilterContainerBlockBody.getUnits().insertAfter(gotoHandlerBodyCondTrueStmt, returnStmt);
handlerFilterContainerBlockBody.getUnits().insertAfter(gotoHandlerBodyCondTrueStmt, returnStmt);
}
handlerFilterContainerBlockBody.getUnits().swapWith(returnStmt, ifRetCondStmt);
dotnetBody.blockEntryPointsManager.swapGotoEntryUnit(ifRetCondStmt, returnStmt);
}
jb.getUnits().addAll(handlerFilterContainerBlockBody.getUnits());

// handler body
if (lastStmtIsNotReturn(handlerBody)) {
if (handlerBody.getUnits().isEmpty() || lastStmtIsNotReturn(handlerBody)) {
// if last stmt is not return, insert goto stmt, to go to end whole block
handlerBody.getUnits().add(Jimple.v().newGotoStmt(nopStmtEnd));
}
Expand Down

0 comments on commit a87831d

Please sign in to comment.