Program: 77397
Project: 77397
Buggy source:
protected IViewerReportDesignHandle getDesignHandle(HttpServletRequest request){
  IViewerReportDesignHandle design=null;
  IReportRunnable reportRunnable=null;
  IReportDocument reportDocumentInstance=ReportEngineService.getInstance().openReportDocument(this.reportDesignName,this.reportDocumentName);
  if (reportDocumentInstance != null) {
    reportRunnable=reportDocumentInstance.getReportRunnable();
    if (IBirtConstants.SERVLET_PATH_FRAMESET.equalsIgnoreCase(request.getServletPath())) {
      this.parameterMap=reportDocumentInstance.getParameterValues();
    }
    if (ParameterAccessor.getParameter(request,ParameterAccessor.PARAM_REPORT_DOCUMENT) != null)     this.documentInUrl=true;
    reportDocumentInstance.close();
  }
  if (reportRunnable == null) {
    try {
      File file=new File(this.reportDesignName);
      if (file.exists()) {
        reportRunnable=ReportEngineService.getInstance().openReportDesign(this.reportDesignName);
      }
 else       if (!ParameterAccessor.isWorkingFolderAccessOnly()) {
        this.reportDesignName=ParameterAccessor.getParameter(request,ParameterAccessor.PARAM_REPORT);
        InputStream is=request.getSession().getServletContext().getResourceAsStream(this.reportDesignName);
        reportRunnable=ReportEngineService.getInstance().openReportDesign(is);
      }
    }
 catch (    EngineException e) {
      this.exception=e;
    }
  }
  if (reportRunnable != null) {
    design=new BirtViewerReportDesignHandle(IViewerReportDesignHandle.RPT_RUNNABLE_OBJECT,reportRunnable);
  }
 else {
    design=new BirtViewerReportDesignHandle(null,reportDesignName);
  }
  return design;
}

Fixed version (ground truth):
protected IViewerReportDesignHandle getDesignHandle(HttpServletRequest request){
  IViewerReportDesignHandle design=null;
  IReportRunnable reportRunnable=null;
  boolean isValidDocument=ParameterAccessor.isValidFilePath(this.reportDocumentName);
  if (isValidDocument) {
    IReportDocument reportDocumentInstance=ReportEngineService.getInstance().openReportDocument(this.reportDesignName,this.reportDocumentName);
    if (reportDocumentInstance != null) {
      reportRunnable=reportDocumentInstance.getReportRunnable();
      if (IBirtConstants.SERVLET_PATH_FRAMESET.equalsIgnoreCase(request.getServletPath())) {
        this.parameterMap=reportDocumentInstance.getParameterValues();
      }
      if (ParameterAccessor.getParameter(request,ParameterAccessor.PARAM_REPORT_DOCUMENT) != null)       this.documentInUrl=true;
      reportDocumentInstance.close();
    }
  }
  if (reportRunnable == null) {
    if (ParameterAccessor.isReportParameterExist(request,ParameterAccessor.PARAM_REPORT_DOCUMENT)) {
      if (isValidDocument)       this.exception=new ViewerException(ResourceConstants.GENERAL_EXCEPTION_DOCUMENT_FILE_ERROR,new String[]{this.reportDocumentName});
 else       this.exception=new ViewerException(ResourceConstants.GENERAL_EXCEPTION_DOCUMENT_ACCESS_ERROR,new String[]{this.reportDocumentName});
      return design;
    }
    if (!ParameterAccessor.isValidFilePath(this.reportDesignName)) {
      this.exception=new ViewerException(ResourceConstants.GENERAL_EXCEPTION_REPORT_ACCESS_ERROR,new String[]{this.reportDesignName});
    }
 else {
      try {
        File file=new File(this.reportDesignName);
        if (file.exists()) {
          reportRunnable=ReportEngineService.getInstance().openReportDesign(this.reportDesignName);
        }
 else         if (!ParameterAccessor.isWorkingFolderAccessOnly()) {
          this.reportDesignName=ParameterAccessor.getParameter(request,ParameterAccessor.PARAM_REPORT);
          InputStream is=request.getSession().getServletContext().getResourceAsStream(this.reportDesignName);
          reportRunnable=ReportEngineService.getInstance().openReportDesign(is);
        }
 else {
          this.exception=new ViewerException(ResourceConstants.GENERAL_EXCEPTION_REPORT_FILE_ERROR,new String[]{this.reportDesignName});
        }
      }
 catch (      EngineException e) {
        this.exception=e;
      }
    }
  }
  if (reportRunnable != null) {
    design=new BirtViewerReportDesignHandle(IViewerReportDesignHandle.RPT_RUNNABLE_OBJECT,reportRunnable);
  }
  return design;
}