Program: 15645
Project: 15645
Buggy source:
/** 
 * @param in Input stream
 * @param defaultEnc Default encoding
 * @throws IOException If an I/O error occurs
 */
public XmlReader(InputStream in,String defaultEnc) throws IOException {
  String encoding=defaultEnc;
  byte header[]=new byte[HEADER_SIZE];
  int n, unread;
  PushbackInputStream pushbackStream=new PushbackInputStream(in,HEADER_SIZE);
  n=pushbackStream.read(header,0,header.length);
  if ((header[0] == (byte)0xEF) && (header[1] == (byte)0xBB) && (header[2] == (byte)0xBF)) {
    encoding="String_Node_Str";
    unread=n - 3;
  }
 else   if ((header[0] == (byte)0xFE) && (header[1] == (byte)0xFF)) {
    encoding="String_Node_Str";
    unread=n - 2;
  }
 else   if ((header[0] == (byte)0xFF) && (header[1] == (byte)0xFE)) {
    encoding="String_Node_Str";
    unread=n - 2;
  }
 else   if ((header[0] == (byte)0x00) && (header[1] == (byte)0x00) && (header[2] == (byte)0xFE)&& (header[3] == (byte)0xFF)) {
    encoding="String_Node_Str";
    unread=n - 4;
  }
 else   if ((header[0] == (byte)0xFF) && (header[1] == (byte)0xFE) && (header[2] == (byte)0x00)&& (header[3] == (byte)0x00)) {
    encoding="String_Node_Str";
    unread=n - 4;
  }
 else {
    unread=n;
    Pattern pattern=Pattern.compile("String_Node_Str");
    Matcher matcher=pattern.matcher(new String(header));
    if (matcher.find()) {
      String enc=matcher.group(1);
      try {
        Charset.forName(enc);
        encoding=enc;
      }
 catch (      Exception e) {
      }
    }
  }
  if (unread > 0) {
    pushbackStream.unread(header,(n - unread),unread);
  }
 else   if (unread < -1) {
    pushbackStream.unread(header,0,0);
  }
  internalInputStreamReader=new InputStreamReader(pushbackStream,encoding);
}

Fixed version (ground truth):
/** 
 * @param in Input stream
 * @param defaultEnc Default encoding
 * @throws IOException If an I/O error occurs
 */
public XmlReader(InputStream in,String defaultEnc) throws IOException {
  String encoding=defaultEnc;
  byte header[]=new byte[HEADER_SIZE];
  int n, unread;
  PushbackInputStream pushbackStream=new PushbackInputStream(in,HEADER_SIZE);
  n=ByteStreams.read(in,header,0,header.length);
  if ((header[0] == (byte)0xEF) && (header[1] == (byte)0xBB) && (header[2] == (byte)0xBF)) {
    encoding="String_Node_Str";
    unread=n - 3;
  }
 else   if ((header[0] == (byte)0xFE) && (header[1] == (byte)0xFF)) {
    encoding="String_Node_Str";
    unread=n - 2;
  }
 else   if ((header[0] == (byte)0xFF) && (header[1] == (byte)0xFE)) {
    encoding="String_Node_Str";
    unread=n - 2;
  }
 else   if ((header[0] == (byte)0x00) && (header[1] == (byte)0x00) && (header[2] == (byte)0xFE)&& (header[3] == (byte)0xFF)) {
    encoding="String_Node_Str";
    unread=n - 4;
  }
 else   if ((header[0] == (byte)0xFF) && (header[1] == (byte)0xFE) && (header[2] == (byte)0x00)&& (header[3] == (byte)0x00)) {
    encoding="String_Node_Str";
    unread=n - 4;
  }
 else {
    unread=n;
    Pattern pattern=Pattern.compile("String_Node_Str");
    Matcher matcher=pattern.matcher(new String(header));
    if (matcher.find()) {
      String enc=matcher.group(1);
      try {
        Charset.forName(enc);
        encoding=enc;
      }
 catch (      Exception e) {
      }
    }
  }
  if (unread > 0) {
    pushbackStream.unread(header,(n - unread),unread);
  }
 else   if (unread < -1) {
    pushbackStream.unread(header,0,0);
  }
  internalInputStreamReader=new InputStreamReader(pushbackStream,encoding);
}