Program: 75537
Project: 75537
Buggy source:
private void generateImageBytes(IImageContent imageContent) throws IOException {
  exportImageHeader(imageContent.getURI());
  boolean isSvg=false;
  TranscoderInput transInput=null;
  Base64 base=new Base64();
  byte[] imageData=null;
  try {
switch (imageContent.getImageSource()) {
case IImageContent.IMAGE_FILE:
      if (imageContent.getURI() == null)       return;
    URL url=reportDesign.findResource(imageContent.getURI(),IResourceLocator.IMAGE);
  InputStream imageInput=url.openStream();
if (imageContent.getURI().endsWith("String_Node_Str")) {
  isSvg=true;
  transInput=new TranscoderInput(imageInput);
}
imageData=new byte[imageInput.available()];
imageInput.read(imageData);
break;
case IImageContent.IMAGE_URL:
if (imageContent.getURI() == null) return;
if (imageContent.getURI().endsWith("String_Node_Str")) {
isSvg=true;
transInput=new TranscoderInput(imageContent.getURI());
}
imageData=imageContent.getData();
break;
case IImageContent.IMAGE_NAME:
case IImageContent.IMAGE_EXPRESSION:
if (imageContent.getData() == null) return;
if (imageContent.getURI().endsWith("String_Node_Str")) {
isSvg=true;
transInput=new TranscoderInput(new ByteArrayInputStream(imageContent.getData()));
}
imageData=imageContent.getData();
break;
}
if (!isSvg) {
pptOutput.write(base.encode(imageData));
}
 else {
JPEGTranscoder transcoder=new JPEGTranscoder();
transcoder.addTranscodingHint(JPEGTranscoder.KEY_QUALITY,new Float(.8));
ByteArrayOutputStream ostream=new ByteArrayOutputStream();
TranscoderOutput transOutput=new TranscoderOutput(ostream);
try {
transcoder.transcode(transInput,transOutput);
}
 catch (TranscoderException e) {
}
ostream.flush();
pptOutput.write(base.encode(ostream.toByteArray()));
}
}
 catch (IOException ioe) {
logger.log(Level.WARNING,ioe.getMessage(),ioe);
}
catch (Throwable t) {
logger.log(Level.WARNING,t.getMessage(),t);
}
}

Fixed version (ground truth):
private void generateImageBytes(IImageContent imageContent) throws IOException {
  if (imageContent.getURI() == null) {
    exportImageHeader(imageContent.getName());
  }
 else {
    exportImageHeader(imageContent.getURI());
  }
  boolean isSvg=false;
  TranscoderInput transInput=null;
  Base64 base=new Base64();
  byte[] imageData=null;
  try {
    if (imageContent.getURI() == null) {
      imageData=imageContent.getData();
      if (imageContent.getExtension() != null && imageContent.getExtension().equalsIgnoreCase("String_Node_Str")) {
        isSvg=true;
      }
    }
 else {
switch (imageContent.getImageSource()) {
case IImageContent.IMAGE_FILE:
        if (imageContent.getURI() == null)         return;
      URL url=reportDesign.findResource(imageContent.getURI(),IResourceLocator.IMAGE);
    InputStream imageInput=url.openStream();
  if (imageContent.getURI().endsWith("String_Node_Str")) {
    isSvg=true;
    transInput=new TranscoderInput(imageInput);
  }
imageData=new byte[imageInput.available()];
imageInput.read(imageData);
break;
case IImageContent.IMAGE_URL:
if (imageContent.getURI() == null) return;
if (imageContent.getURI().endsWith("String_Node_Str")) {
isSvg=true;
transInput=new TranscoderInput(imageContent.getURI());
}
imageData=imageContent.getData();
break;
case IImageContent.IMAGE_NAME:
case IImageContent.IMAGE_EXPRESSION:
if (imageContent.getData() == null || imageContent.getURI() == null) return;
if (imageContent.getURI().endsWith("String_Node_Str")) {
isSvg=true;
transInput=new TranscoderInput(new ByteArrayInputStream(imageContent.getData()));
}
imageData=imageContent.getData();
break;
default :
imageData=imageContent.getData();
break;
}
}
if (!isSvg) {
pptOutput.write(base.encode(imageData));
}
 else {
JPEGTranscoder transcoder=new JPEGTranscoder();
transcoder.addTranscodingHint(JPEGTranscoder.KEY_QUALITY,new Float(.8));
ByteArrayOutputStream ostream=new ByteArrayOutputStream();
TranscoderOutput transOutput=new TranscoderOutput(ostream);
try {
transcoder.transcode(transInput,transOutput);
}
 catch (TranscoderException e) {
}
ostream.flush();
pptOutput.write(base.encode(ostream.toByteArray()));
}
}
 catch (IOException ioe) {
logger.log(Level.WARNING,ioe.getMessage(),ioe);
}
catch (Throwable t) {
logger.log(Level.WARNING,t.getMessage(),t);
}
}