Program: 72018
Project: 72018
Buggy source:
/** 
 * get intrinsic dimension of image in pixels. Now only support png, bmp, jpg, gif.
 * @param in
 * @return
 * @throws IOException
 * @throws MalformedURLException
 * @throws BadElementException
 */
protected Dimension getIntrinsicDimension(IImageContent content) throws BadElementException, MalformedURLException, IOException {
  Image image=null;
  String uri=content.getURI();
  String mimeType=content.getMIMEType();
  String extension=content.getExtension();
  if (FlashFile.isFlash(mimeType,uri,extension)) {
    return null;
  }
switch (content.getImageSource()) {
case IImageContent.IMAGE_FILE:
    ReportDesignHandle design=content.getReportContent().getDesign().getReportDesign();
  URL url=design.findResource(uri,IResourceLocator.IMAGE);
InputStream in=url.openStream();
try {
byte[] buffer;
if (SvgFile.isSvg(content.getURI())) {
  buffer=SvgFile.transSvgToArray(in);
}
 else {
  ArrayList<Byte> bytes=new ArrayList<Byte>();
  int data=in.read();
  while (data != -1) {
    bytes.add((byte)data);
    data=in.read();
  }
  buffer=new byte[bytes.size()];
  for (int i=0; i < buffer.length; i++) {
    buffer[i]=bytes.get(i);
  }
}
image=Image.getInstance(buffer);
}
 catch (Exception ex) {
logger.log(Level.WARNING,ex.getMessage(),ex);
}
 finally {
in.close();
}
break;
case IImageContent.IMAGE_NAME:
case IImageContent.IMAGE_EXPRESSION:
byte[] data=content.getData();
in=new ByteArrayInputStream(data);
if (SvgFile.isSvg(mimeType,uri,extension)) data=SvgFile.transSvgToArray(in);
image=Image.getInstance(data);
break;
case IImageContent.IMAGE_URL:
if (SvgFile.isSvg(uri)) {
image=Image.getInstance(SvgFile.transSvgToArray(uri));
}
 else {
image=Image.getInstance(new URL(content.getURI()));
}
break;
default :
assert(false);
}
if (image != null) {
int resolutionX=0;
int resolutionY=0;
int contentResolution=content.getResolution();
if (contentResolution != 0) {
resolutionX=contentResolution;
resolutionY=contentResolution;
}
 else {
resolutionX=image.getDpiX();
resolutionY=image.getDpiY();
if (0 == resolutionX || 0 == resolutionY) {
resolutionX=context.getDpi();
resolutionY=context.getDpi();
}
if (0 == resolutionX || 0 == resolutionY) {
resolutionX=96;
resolutionY=96;
}
}
return new Dimension((int)(image.plainWidth() * 1000 / resolutionX * 72),(int)(image.plainHeight() * 1000 / resolutionY * 72));
}
return null;
}

Fixed version (ground truth):
/** 
 * get intrinsic dimension of image in pixels. Now only support png, bmp, jpg, gif.
 * @param in
 * @return
 * @throws IOException
 * @throws MalformedURLException
 * @throws BadElementException
 */
protected Dimension getIntrinsicDimension(IImageContent content) throws BadElementException, MalformedURLException, IOException {
  Image image=null;
  String uri=content.getURI();
  String mimeType=content.getMIMEType();
  String extension=content.getExtension();
  if (FlashFile.isFlash(mimeType,uri,extension)) {
    return null;
  }
switch (content.getImageSource()) {
case IImageContent.IMAGE_FILE:
    ReportDesignHandle design=content.getReportContent().getDesign().getReportDesign();
  URL url=design.findResource(uri,IResourceLocator.IMAGE);
InputStream in=url.openStream();
try {
byte[] buffer;
if (SvgFile.isSvg(content.getURI())) {
  buffer=SvgFile.transSvgToArray(in);
}
 else {
  ArrayList<Byte> bytes=new ArrayList<Byte>();
  int data=in.read();
  while (data != -1) {
    bytes.add((byte)data);
    data=in.read();
  }
  buffer=new byte[bytes.size()];
  for (int i=0; i < buffer.length; i++) {
    buffer[i]=bytes.get(i);
  }
}
image=Image.getInstance(buffer);
}
 catch (Exception ex) {
logger.log(Level.WARNING,ex.getMessage(),ex);
}
 finally {
in.close();
}
break;
case IImageContent.IMAGE_NAME:
case IImageContent.IMAGE_EXPRESSION:
byte[] data=content.getData();
in=new ByteArrayInputStream(data);
if (SvgFile.isSvg(mimeType,uri,extension)) data=SvgFile.transSvgToArray(in);
image=Image.getInstance(data);
break;
case IImageContent.IMAGE_URL:
if (SvgFile.isSvg(uri)) {
image=Image.getInstance(SvgFile.transSvgToArray(uri));
}
 else {
image=Image.getInstance(new URL(content.getURI()));
}
break;
default :
assert(false);
}
if (image != null) {
int resolutionX=0;
int resolutionY=0;
int contentResolution=content.getResolution();
if (contentResolution != 0) {
resolutionX=contentResolution;
resolutionY=contentResolution;
}
 else {
if (0 == resolutionX || 0 == resolutionY) {
resolutionX=context.getDpi();
resolutionY=context.getDpi();
}
if (0 == resolutionX || 0 == resolutionY) {
resolutionX=96;
resolutionY=96;
}
}
return new Dimension((int)(image.plainWidth() * 1000 / resolutionX * 72),(int)(image.plainHeight() * 1000 / resolutionY * 72));
}
return null;
}