Program: 91466
Project: 91466
Buggy source:
private void buildDiffs(final StringBuilder d,final List<StyleRange> styles,IProgressMonitor monitor,boolean trace) throws OperationCanceledException, IOException {
  final String[] currentEncoding=new String[1];
  if (trace)   GitTraceLocation.getTrace().traceEntry(GitTraceLocation.HISTORYVIEW.getLocation());
  if (commit.getParentCount() > 1) {
    d.append(UIText.CommitMessageViewer_CanNotRenderDiffMessage);
    return;
  }
  try {
    monitor.beginTask(UIText.CommitMessageViewer_BuildDiffListTaskName,currentDiffs.size());
    BufferedOutputStream bos=new SafeBufferedOutputStream(new ByteArrayOutputStream(){
      @Override public synchronized void write(      byte[] b,      int off,      int len){
        super.write(b,off,len);
        if (currentEncoding[0] == null)         d.append(toString());
 else         try {
          d.append(toString(currentEncoding[0]));
        }
 catch (        UnsupportedEncodingException e) {
          d.append(toString());
        }
        reset();
      }
    }
);
    final DiffFormatter diffFmt=new MessageViewerFormatter(bos,styles,d,hunkheaderColor,linesAddedColor,linesRemovedColor);
    for (    FileDiff currentDiff : currentDiffs) {
      if (monitor.isCanceled())       throw new OperationCanceledException();
      if (currentDiff.getBlobs().length == 2) {
        String path=currentDiff.getNewPath();
        monitor.setTaskName(NLS.bind(UIText.CommitMessageViewer_BuildDiffTaskName,path));
        currentEncoding[0]=CompareCoreUtils.getResourceEncoding(db,path);
        d.append(LF);
        int start=d.length();
        String pathLine=formatPathLine(path);
        int len=pathLine.length();
        d.append(pathLine).append(LF);
        styles.add(new StyleRange(start,len,darkGrey,null));
        currentDiff.outputDiff(d,db,diffFmt,true);
        diffFmt.flush();
      }
      monitor.worked(1);
    }
  }
  finally {
    monitor.done();
    if (trace)     GitTraceLocation.getTrace().traceExit(GitTraceLocation.HISTORYVIEW.getLocation());
  }
}

Fixed version (ground truth):
private void buildDiffs(final StringBuilder d,final List<StyleRange> styles,IProgressMonitor monitor,boolean trace) throws OperationCanceledException, IOException {
  final String[] currentEncoding=new String[1];
  if (trace)   GitTraceLocation.getTrace().traceEntry(GitTraceLocation.HISTORYVIEW.getLocation());
  if (commit.getParentCount() > 1) {
    d.append(UIText.CommitMessageViewer_CanNotRenderDiffMessage);
    return;
  }
  try {
    monitor.beginTask(UIText.CommitMessageViewer_BuildDiffListTaskName,currentDiffs.size());
    BufferedOutputStream bos=new SafeBufferedOutputStream(new ByteArrayOutputStream(){
      @Override public synchronized void write(      byte[] b,      int off,      int len){
        super.write(b,off,len);
        try {
          if (currentEncoding[0] == null)           d.append(toString("String_Node_Str"));
 else           d.append(toString(currentEncoding[0]));
        }
 catch (        UnsupportedEncodingException e) {
          d.append(toString());
        }
        reset();
      }
    }
);
    final DiffFormatter diffFmt=new MessageViewerFormatter(bos,styles,d,hunkheaderColor,linesAddedColor,linesRemovedColor);
    for (    FileDiff currentDiff : currentDiffs) {
      if (monitor.isCanceled())       throw new OperationCanceledException();
      if (currentDiff.getBlobs().length == 2) {
        String path=currentDiff.getNewPath();
        monitor.setTaskName(NLS.bind(UIText.CommitMessageViewer_BuildDiffTaskName,path));
        currentEncoding[0]=CompareCoreUtils.getResourceEncoding(db,path);
        d.append(LF);
        int start=d.length();
        String pathLine=formatPathLine(path);
        int len=pathLine.length();
        d.append(pathLine).append(LF);
        styles.add(new StyleRange(start,len,darkGrey,null));
        currentDiff.outputDiff(d,db,diffFmt,true);
        diffFmt.flush();
      }
      monitor.worked(1);
    }
  }
  finally {
    monitor.done();
    if (trace)     GitTraceLocation.getTrace().traceExit(GitTraceLocation.HISTORYVIEW.getLocation());
  }
}