Program: 76559
Project: 76559
Buggy source:
/** 
 * Returns report design handle
 * @return IViewerReportDesignHandle
 * @throws Exception
 */
protected IViewerReportDesignHandle getDesignHandle() throws Exception {
  if (viewer == null)   return null;
  IViewerReportDesignHandle design=null;
  IReportRunnable reportRunnable=null;
  HttpServletRequest request=(HttpServletRequest)pageContext.getRequest();
  String designFile=ParameterAccessor.getReport(request,viewer.getReportDesign());
  String documentFile=ParameterAccessor.getReportDocument(request,viewer.getReportDocument(),false);
  boolean isValidDocument=ParameterAccessor.isValidFilePath(documentFile);
  if (documentFile != null && isValidDocument) {
    IReportDocument reportDocumentInstance=ReportEngineService.getInstance().openReportDocument(designFile,documentFile,getModuleOptions());
    if (reportDocumentInstance != null) {
      this.documentInUrl=true;
      reportRunnable=reportDocumentInstance.getReportRunnable();
      reportDocumentInstance.close();
    }
  }
  if (reportRunnable == null) {
    if (documentFile != null && designFile == null) {
      if (isValidDocument)       throw new ViewerException(ResourceConstants.GENERAL_EXCEPTION_DOCUMENT_FILE_ERROR,new String[]{documentFile});
 else       throw new ViewerException(ResourceConstants.GENERAL_EXCEPTION_DOCUMENT_ACCESS_ERROR,new String[]{documentFile});
    }
    if (!ParameterAccessor.isValidFilePath(designFile)) {
      throw new ViewerException(ResourceConstants.GENERAL_EXCEPTION_REPORT_ACCESS_ERROR,new String[]{designFile});
    }
 else {
      reportRunnable=BirtUtility.getRunnableFromDesignFile(request,designFile,this.getModuleOptions());
      if (reportRunnable == null) {
        throw new ViewerException(ResourceConstants.GENERAL_EXCEPTION_REPORT_FILE_ERROR,new String[]{designFile});
      }
    }
  }
  if (reportRunnable != null) {
    design=new BirtViewerReportDesignHandle(IViewerReportDesignHandle.RPT_RUNNABLE_OBJECT,reportRunnable);
  }
  return design;
}

Fixed version (ground truth):
/** 
 * Returns report design handle
 * @return IViewerReportDesignHandle
 * @throws Exception
 */
protected IViewerReportDesignHandle getDesignHandle() throws Exception {
  if (viewer == null)   return null;
  IViewerReportDesignHandle design=null;
  IReportRunnable reportRunnable=null;
  HttpServletRequest request=(HttpServletRequest)pageContext.getRequest();
  String designFile=ParameterAccessor.getReport(request,viewer.getReportDesign());
  String documentFile=ParameterAccessor.getReportDocument(request,viewer.getReportDocument(),false);
  boolean isValidDocument=ParameterAccessor.isValidFilePath(ParameterAccessor.getParameter(request,ParameterAccessor.PARAM_REPORT_DOCUMENT));
  if (documentFile != null && isValidDocument) {
    IReportDocument reportDocumentInstance=ReportEngineService.getInstance().openReportDocument(designFile,documentFile,getModuleOptions());
    if (reportDocumentInstance != null) {
      this.documentInUrl=true;
      reportRunnable=reportDocumentInstance.getReportRunnable();
      reportDocumentInstance.close();
    }
  }
  if (reportRunnable == null) {
    if (documentFile != null && designFile == null) {
      if (isValidDocument)       throw new ViewerException(ResourceConstants.GENERAL_EXCEPTION_DOCUMENT_FILE_ERROR,new String[]{documentFile});
 else       throw new ViewerException(ResourceConstants.GENERAL_EXCEPTION_DOCUMENT_ACCESS_ERROR,new String[]{documentFile});
    }
    if (!ParameterAccessor.isValidFilePath(ParameterAccessor.getParameter(request,ParameterAccessor.PARAM_REPORT))) {
      throw new ViewerException(ResourceConstants.GENERAL_EXCEPTION_REPORT_ACCESS_ERROR,new String[]{designFile});
    }
 else {
      reportRunnable=BirtUtility.getRunnableFromDesignFile(request,designFile,this.getModuleOptions());
      if (reportRunnable == null) {
        throw new ViewerException(ResourceConstants.GENERAL_EXCEPTION_REPORT_FILE_ERROR,new String[]{designFile});
      }
    }
  }
  if (reportRunnable != null) {
    design=new BirtViewerReportDesignHandle(IViewerReportDesignHandle.RPT_RUNNABLE_OBJECT,reportRunnable);
  }
  return design;
}