Program: 82312
Project: 82312
Buggy source:
/** 
 * Escapes '&', '<', '>', '"', and optionally ''' to their XML entity equivalents. The portion of the input string between start (inclusive) and end (exclusive) is scanned.  The output is appended to the given StringBuilder.
 * @param code the input String
 * @param start the first character position to scan.
 * @param end the character position following the last character to scan.
 * @param quoteApostrophe if true, the &apos; character is quoted as&amp;apos;
 * @param builder a StringBuilder to be appended with the output.
 */
public static void escapeXml(String code,int start,int end,boolean quoteApostrophe,StringBuilder builder){
  int lastIndex=0;
  int len=end - start;
  char[] c=new char[len];
  code.getChars(start,end,c,0);
  for (int i=0; i < len; i++) {
    if ((c[i] >= '\uD800') && (c[i] <= '\uDBFF')) {
      builder.append(c,lastIndex,i - lastIndex);
      builder.append("String_Node_Str");
      lastIndex=i + 1;
      break;
    }
 else     if ((c[i] >= '\uDC00') && (c[i] <= '\uDFFF')) {
      builder.append(c,lastIndex,i - lastIndex);
      builder.append("String_Node_Str");
      lastIndex=i + 1;
      break;
    }
 else     if (c[i] == '\0') {
      builder.append(c,lastIndex,i - lastIndex);
      builder.append("String_Node_Str");
      lastIndex=i + 1;
      break;
    }
 else     if (c[i] == '\uffff') {
      builder.append(c,lastIndex,i - lastIndex);
      builder.append("String_Node_Str");
      lastIndex=i + 1;
      break;
    }
 else     if (c[i] == '\ufffe') {
      builder.append(c,lastIndex,i - lastIndex);
      builder.append("String_Node_Str");
      lastIndex=i + 1;
    }
 else     if (c[i] == '&') {
      builder.append(c,lastIndex,i - lastIndex);
      builder.append("String_Node_Str");
      lastIndex=i + 1;
    }
 else     if (c[i] == '>') {
      builder.append(c,lastIndex,i - lastIndex);
      builder.append("String_Node_Str");
      lastIndex=i + 1;
    }
 else     if (c[i] == '<') {
      builder.append(c,lastIndex,i - lastIndex);
      builder.append("String_Node_Str");
      lastIndex=i + 1;
    }
 else     if (c[i] == '\"') {
      builder.append(c,lastIndex,i - lastIndex);
      builder.append("String_Node_Str");
      lastIndex=i + 1;
    }
 else     if (c[i] == '\'') {
      if (quoteApostrophe) {
        builder.append(c,lastIndex,i - lastIndex);
        builder.append("String_Node_Str");
        lastIndex=i + 1;
      }
    }
  }
  builder.append(c,lastIndex,len - lastIndex);
}

Fixed version (ground truth):
/** 
 * Escapes '&', '<', '>', '"', and optionally ''' to their XML entity equivalents. The portion of the input string between start (inclusive) and end (exclusive) is scanned.  The output is appended to the given StringBuilder.
 * @param code the input String
 * @param start the first character position to scan.
 * @param end the character position following the last character to scan.
 * @param quoteApostrophe if true, the &apos; character is quoted as&amp;apos;
 * @param builder a StringBuilder to be appended with the output.
 */
public static void escapeXml(String code,int start,int end,boolean quoteApostrophe,StringBuilder builder){
  int lastIndex=0;
  int len=end - start;
  char[] c=new char[len];
  code.getChars(start,end,c,0);
  for (int i=0; i < len; i++) {
    if ((c[i] < '\u0020')) {
      builder.append(c,lastIndex,i - lastIndex);
      if (c[i] == '\u0000') {
        builder.append("String_Node_Str");
      }
 else       if (c[i] == '\u0009') {
        builder.append("String_Node_Str");
      }
 else       if (c[i] == '\n') {
        builder.append("String_Node_Str");
      }
 else       if (c[i] == '\r') {
        builder.append("String_Node_Str");
      }
 else {
        builder.append("String_Node_Str" + charToHex(c[i]) + "String_Node_Str");
      }
      lastIndex=i + 1;
    }
 else     if (((c[i] >= '\u007F') && (c[i] <= '\u0084')) || ((c[i] >= '\u0086') && (c[i] <= '\u009F')) || ((c[i] >= '\uD800') && (c[i] <= '\uDBFF'))|| ((c[i] >= '\uDC00') && (c[i] <= '\uDFFF'))|| ((c[i] >= '\uFDD0') && (c[i] <= '\uFDDF'))|| (c[i] == '\u00A0')|| (c[i] == '\uFFFF')|| (c[i] == '\uFFFE')) {
      builder.append(c,lastIndex,i - lastIndex);
      builder.append("String_Node_Str" + charToHex(c[i]) + "String_Node_Str");
      lastIndex=i + 1;
    }
 else     if (c[i] == '&') {
      builder.append(c,lastIndex,i - lastIndex);
      builder.append("String_Node_Str");
      lastIndex=i + 1;
    }
 else     if (c[i] == '>') {
      builder.append(c,lastIndex,i - lastIndex);
      builder.append("String_Node_Str");
      lastIndex=i + 1;
    }
 else     if (c[i] == '<') {
      builder.append(c,lastIndex,i - lastIndex);
      builder.append("String_Node_Str");
      lastIndex=i + 1;
    }
 else     if (c[i] == '\"') {
      builder.append(c,lastIndex,i - lastIndex);
      builder.append("String_Node_Str");
      lastIndex=i + 1;
    }
 else     if (c[i] == '\'') {
      if (quoteApostrophe) {
        builder.append(c,lastIndex,i - lastIndex);
        builder.append("String_Node_Str");
        lastIndex=i + 1;
      }
    }
 else     if (c[i] > '\u007F') {
      builder.append(c,lastIndex,i - lastIndex);
      builder.append("String_Node_Str" + charToHex(c[i]) + "String_Node_Str");
      lastIndex=i + 1;
    }
  }
  builder.append(c,lastIndex,len - lastIndex);
}