Program: 69894
Project: 69894
Buggy source:
protected void init() throws BirtException {
  if (PropertyUtil.isInlineElement(image)) {
    root=new ImageInlineContainer(parent,context,image);
  }
 else {
    root=new ImageBlockContainer(parent,context,image);
  }
  root.initialize();
  root.setAllocatedWidth(parent.getMaxAvaWidth());
  root.setMaxAvaWidth(root.getContentWidth());
  Dimension contentDimension=getSpecifiedDimension(image,root.getContentWidth(),true);
  ImageArea imageArea=createImageArea(image);
  int maxHeight=root.getMaxAvaHeight();
  int maxWidth=root.getMaxAvaWidth();
  int cHeight=contentDimension.getHeight();
  int cWidth=contentDimension.getWidth();
  int actualHeight=cHeight;
  int actualWidth=cWidth;
  if (cHeight > maxHeight || cWidth > maxWidth) {
    if (fitToContainer) {
      float rh=((float)maxHeight) / cHeight;
      float rw=((float)maxWidth) / cWidth;
      if (rh > rw) {
        actualHeight=(int)((float)cHeight * maxWidth / cWidth);
        actualWidth=maxWidth;
      }
 else {
        actualHeight=maxHeight;
        actualWidth=(int)((float)cWidth * maxHeight / cHeight);
      }
      imageArea.setWidth(actualWidth);
      imageArea.setHeight(actualHeight);
      root.setContentWidth(imageArea.getWidth());
      root.setContentHeight(imageArea.getHeight());
    }
 else {
      imageArea.setWidth(actualWidth);
      imageArea.setHeight(actualHeight);
      root.setNeedClip(true);
      root.setAllocatedHeight(Math.min(maxHeight,cHeight));
      root.setAllocatedWidth(Math.min(maxWidth,cWidth));
    }
  }
 else {
    imageArea.setWidth(actualWidth);
    imageArea.setHeight(actualHeight);
    root.setContentWidth(imageArea.getWidth());
    root.setContentHeight(imageArea.getHeight());
  }
  root.addChild(imageArea);
  imageArea.setPosition(root.getContentX(),root.getContentY());
  processChartLegend(image,imageArea);
  root.finished=false;
}

Fixed version (ground truth):
protected void init() throws BirtException {
  if (PropertyUtil.isInlineElement(image)) {
    root=new ImageInlineContainer(parent,context,image);
  }
 else {
    root=new ImageBlockContainer(parent,context,image);
  }
  root.initialize();
  root.setAllocatedWidth(parent.getMaxAvaWidth());
  root.setMaxAvaWidth(root.getContentWidth());
  Dimension contentDimension=getSpecifiedDimension(image,root.getContentWidth(),true);
  ImageArea imageArea=createImageArea(image);
  int maxHeight=root.getMaxAvaHeight();
  int maxWidth=root.getMaxAvaWidth();
  int cHeight=contentDimension.getHeight();
  int cWidth=contentDimension.getWidth();
  int actualHeight=cHeight;
  int actualWidth=cWidth;
  if (cHeight > maxHeight || cWidth > maxWidth) {
    if (fitToContainer) {
      float rh=((float)maxHeight) / cHeight;
      float rw=((float)maxWidth) / cWidth;
      if (rh > rw) {
        actualHeight=(int)((float)cHeight * maxWidth / cWidth);
        actualWidth=maxWidth;
      }
 else {
        actualHeight=maxHeight;
        actualWidth=(int)((float)cWidth * maxHeight / cHeight);
      }
      imageArea.setWidth(actualWidth);
      imageArea.setHeight(actualHeight);
      root.setContentWidth(imageArea.getWidth());
      root.setContentHeight(imageArea.getHeight());
    }
 else {
      if (context.getPageOverflow() == IPDFRenderOption.FIT_TO_PAGE_SIZE || context.getPageOverflow() == IPDFRenderOption.ENLARGE_PAGE_SIZE) {
        imageArea.setWidth(actualWidth);
        imageArea.setHeight(actualHeight);
        root.setContentHeight(actualHeight);
        root.setContentWidth(actualWidth);
      }
 else {
        imageArea.setWidth(actualWidth);
        imageArea.setHeight(actualHeight);
        root.setNeedClip(true);
        root.setAllocatedHeight(Math.min(maxHeight,cHeight));
        root.setAllocatedWidth(Math.min(maxWidth,cWidth));
      }
    }
  }
 else {
    imageArea.setWidth(actualWidth);
    imageArea.setHeight(actualHeight);
    root.setContentWidth(imageArea.getWidth());
    root.setContentHeight(imageArea.getHeight());
  }
  root.addChild(imageArea);
  imageArea.setPosition(root.getContentX(),root.getContentY());
  processChartLegend(image,imageArea);
  root.finished=false;
}