Program: 187057
Project: 187057
Buggy source:
/** 
 * Link returns and exceptionhandler of inlined blocks. This assumes that the next codeblock has the same exceptionhandler set as the original invoke statement.
 * @param graph the current graph.
 * @param firstBlock the index of the first inlined block.
 * @param next the next block after the inlined code.
 * @param invokeStmt the invocation statement.
 */
private void linkBlocks(ControlFlowGraph graph,int firstBlock,BasicBlock next,InvokeStmt invokeStmt){
  int nextIndex=next.getBlockIndex();
  List exHandler=next.getExceptionHandlers();
  Variable resultVar=null;
  if (graph.getType() == ControlFlowGraph.TYPE_QUAD) {
    resultVar=((QuadInvoke)invokeStmt).getAssignedVar();
  }
  for (int i=firstBlock; i < nextIndex; i++) {
    BasicBlock block=graph.getBlock(i);
    for (Iterator it=exHandler.iterator(); it.hasNext(); ) {
      BasicBlock.ExceptionHandler handler=(BasicBlock.ExceptionHandler)it.next();
      block.addExceptionHandler(handler);
    }
    ControlFlowStmt cf=block.getControlFlowStmt();
    if (cf != null && cf instanceof ReturnStmt) {
      CodeBlock code=block.getCodeBlock();
      code.deleteStatement(code.size() - 1);
      if (resultVar != null) {
        QuadReturn ret=(QuadReturn)cf;
        block.getQuadCode().addStatement(new QuadCopy(ret.getType(),resultVar,ret.getReturnVar()));
      }
      block.setNextBlock(next);
    }
  }
}

Fixed version (ground truth):
/** 
 * Link returns and exceptionhandler of inlined blocks. This assumes that the next codeblock has the same exceptionhandler set as the original invoke statement.
 * @param graph the current graph.
 * @param firstBlock the index of the first inlined block.
 * @param next the next block after the inlined code.
 * @param invokeStmt the invocation statement.
 * @param offset local variable slot offset
 * @throws com.jopdesign.libgraph.cfg.GraphException if calculating the stackdepth fails
 */
private void linkBlocks(ControlFlowGraph graph,int firstBlock,BasicBlock next,InvokeStmt invokeStmt,int offset) throws GraphException {
  int nextIndex=next.getBlockIndex();
  List exHandler=next.getExceptionHandlers();
  Variable resultVar=null;
  if (graph.getType() == ControlFlowGraph.TYPE_QUAD) {
    resultVar=((QuadInvoke)invokeStmt).getAssignedVar();
  }
 else {
    boolean error;
    StackWalker stackWalker=new StackWalker();
    CFGWalker walker=new CFGWalker(graph,stackWalker,firstBlock,nextIndex - 1);
    stackWalker.setStack(((StackInvoke)invokeStmt).getPopTypes());
    error=walker.walkDFS(firstBlock);
    if (error) {
      throw new GraphException("String_Node_Str");
    }
    if (!walker.allVisited()) {
      throw new GraphException("String_Node_Str");
    }
  }
  for (int i=firstBlock; i < nextIndex; i++) {
    BasicBlock block=graph.getBlock(i);
    for (Iterator it=exHandler.iterator(); it.hasNext(); ) {
      BasicBlock.ExceptionHandler handler=(BasicBlock.ExceptionHandler)it.next();
      block.addExceptionHandler(handler);
    }
    ControlFlowStmt cf=block.getControlFlowStmt();
    if (cf != null && cf instanceof ReturnStmt) {
      CodeBlock code=block.getCodeBlock();
      code.deleteStatement(code.size() - 1);
      if (resultVar != null) {
        QuadReturn ret=(QuadReturn)cf;
        block.getQuadCode().addStatement(new QuadCopy(ret.getType(),resultVar,ret.getReturnVar()));
      }
 else       if (graph.getType() == ControlFlowGraph.TYPE_STACK) {
        StackCode stackCode=block.getStackCode();
        if (stackCode.getEndStack().length != 0) {
          createStackReturnCleanup(stackCode,((ReturnStmt)cf).getType(),offset);
        }
      }
      block.setNextBlock(next);
    }
  }
}