Program: 76267
Project: 76267
Buggy source:
/** 
 * Handle image operate.
 * @param request incoming http request
 * @param response http response
 * @exception ServletException
 * @exception IOException
 */
protected void doService(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException {
  BaseAttributeBean attrBean=(BaseAttributeBean)request.getAttribute(IBirtConstants.ATTRIBUTE_BEAN);
  OutputStream out=response.getOutputStream();
  GetUpdatedObjectsResponse upResponse=new GetUpdatedObjectsResponse();
  IContext context=new BirtContext(request,response);
  Operation op=null;
  try {
    if (ParameterAccessor.isGetImageOperator(request)) {
      BirtRenderImageActionHandler renderImageHandler=new BirtRenderImageActionHandler(context,op,upResponse);
      renderImageHandler.execute();
    }
 else {
      boolean isPrint=false;
      if (IBirtConstants.ACTION_PRINT.equalsIgnoreCase(attrBean.getAction())) {
        isPrint=true;
        out=new ByteArrayOutputStream();
      }
      BirtRunAndRenderActionHandler runAndRenderHandler=new BirtRunAndRenderActionHandler(context,op,upResponse,out);
      runAndRenderHandler.execute();
      if (isPrint) {
        InputStream inputStream=new ByteArrayInputStream(out.toString().getBytes());
        BirtUtility.doPrintAction(inputStream,request,response);
      }
    }
  }
 catch (  RemoteException e) {
    AxisFault fault=(AxisFault)e;
    response.setContentType("String_Node_Str");
    BirtUtility.writeMessage(response.getOutputStream(),ParameterAccessor.htmlEncode(fault.getFaultString()),IBirtConstants.MSG_ERROR);
  }
}

Fixed version (ground truth):
/** 
 * Handle image operate.
 * @param request incoming http request
 * @param response http response
 * @exception ServletException
 * @exception IOException
 */
protected void doService(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException {
  BaseAttributeBean attrBean=(BaseAttributeBean)request.getAttribute(IBirtConstants.ATTRIBUTE_BEAN);
  OutputStream out=response.getOutputStream();
  GetUpdatedObjectsResponse upResponse=new GetUpdatedObjectsResponse();
  IContext context=new BirtContext(request,response);
  Operation op=null;
  try {
    if (ParameterAccessor.isGetImageOperator(request)) {
      BirtRenderImageActionHandler renderImageHandler=new BirtRenderImageActionHandler(context,op,upResponse);
      renderImageHandler.execute();
    }
 else {
      boolean isPrint=false;
      if (IBirtConstants.ACTION_PRINT.equalsIgnoreCase(attrBean.getAction())) {
        isPrint=true;
        out=new ByteArrayOutputStream();
      }
      BirtRunAndRenderActionHandler runAndRenderHandler=new BirtRunAndRenderActionHandler(context,op,upResponse,out);
      runAndRenderHandler.execute();
      if (isPrint) {
        InputStream inputStream=new ByteArrayInputStream(((ByteArrayOutputStream)out).toByteArray());
        BirtUtility.doPrintAction(inputStream,request,response);
      }
    }
  }
 catch (  RemoteException e) {
    if (!ParameterAccessor.isGetImageOperator(request)) {
      response.setContentType("String_Node_Str");
      BirtUtility.appendErrorMessage(response.getOutputStream(),e);
    }
  }
}