Program: 5416
Project: 5416
Buggy source:
public Value<?> readValueRec() throws IOException {
  final int first=stream.read();
  if (first == END_VALUE) {
    return BVOID;
  }
 else   if (first == INTEGER_VALUE) {
    int i=0;
    boolean end=false;
    while (!end) {
      final int readInt=stream.read();
      if (readInt < 0) {
        throw new EOFException();
      }
 else       if (readInt == END_VALUE) {
        end=true;
      }
 else       if ((readInt >= '0' && readInt <= '9') || (i == 0 && readInt == '-')) {
        charBuffer[i]=(char)readInt;
        i++;
      }
 else {
        throw new IOException("String_Node_Str");
      }
    }
    return new IntegerValue(Long.valueOf(new String(charBuffer,0,i)));
  }
 else   if (first == LIST_VALUE) {
    final List<Value<?>> list=new ArrayList<Value<?>>();
    boolean end=false;
    while (!end) {
      final Value<?> val=readValueRec();
      if (val == BVOID) {
        end=true;
      }
 else {
        list.add(val);
      }
    }
    return new ListValue(list);
  }
 else   if (first == DICTIONARY_VALUE) {
    final SortedMap<String,Value<?>> map=new TreeMap<String,Value<?>>();
    String lastKeyStr=null;
    boolean end=false;
    while (!end) {
      final Value<?> key=readValueRec();
      if (key != null && !(key instanceof StringValue)) {
        throw new IOException("String_Node_Str");
      }
      if (key == BVOID) {
        end=true;
      }
 else {
        final String currKeyStr=((StringValue)key).getStringValue();
        if (lastKeyStr != null) {
          final int cmp=lastKeyStr.compareTo(currKeyStr);
          if (cmp > 0) {
            throw new IOException("String_Node_Str");
          }
 else           if (cmp == 0) {
            throw new IOException("String_Node_Str");
          }
        }
        lastKeyStr=currKeyStr;
        final Value<?> val=readValueRec();
        if (val == null) {
          throw new IOException("String_Node_Str");
        }
        map.put(new String((byte[])key.getValue(),Bencode.UTF8),val);
      }
    }
    return new DictionaryValue(map);
  }
 else   if (first >= STRING_VALUE_FROM && first <= STRING_VALUE_TO) {
    charBuffer[0]=(char)first;
    int i=1;
    boolean end=false;
    while (!end) {
      final int readInt=stream.read();
      if (readInt < 0) {
        throw new EOFException();
      }
 else       if (readInt == ':') {
        end=true;
      }
 else       if (readInt >= '0' && readInt <= '9') {
        charBuffer[i]=(char)readInt;
        i++;
      }
 else {
        throw new IOException("String_Node_Str");
      }
    }
    final long lsize=Long.parseLong(new String(charBuffer,0,i));
    if (lsize > Integer.MAX_VALUE) {
      throw new IOException("String_Node_Str");
    }
    final int size=(int)lsize;
    if (byteBuffer.length < lsize) {
      byteBuffer=new byte[Math.max(size + 1,byteBuffer.length * 2 + 1)];
    }
    final int howMany=stream.read(byteBuffer,0,size);
    if (howMany != size) {
      throw new EOFException();
    }
    return new StringValue(Arrays.copyOf(byteBuffer,size));
  }
 else {
    if (first == -1) {
      return null;
    }
 else {
      throw new IOException("String_Node_Str" + Integer.toHexString(first));
    }
  }
}

Fixed version (ground truth):
public Value<?> readValueRec() throws IOException {
  final int first=stream.read();
  if (first == END_VALUE) {
    return BVOID;
  }
 else   if (first == INTEGER_VALUE) {
    int i=0;
    boolean end=false;
    while (!end) {
      final int readInt=stream.read();
      if (readInt < 0) {
        throw new EOFException();
      }
 else       if (readInt == END_VALUE) {
        end=true;
      }
 else       if ((readInt >= '0' && readInt <= '9') || (i == 0 && readInt == '-')) {
        charBuffer[i]=(char)readInt;
        i++;
      }
 else {
        throw new IOException("String_Node_Str");
      }
    }
    return new IntegerValue(Long.valueOf(new String(charBuffer,0,i)));
  }
 else   if (first == LIST_VALUE) {
    final List<Value<?>> list=new ArrayList<Value<?>>();
    boolean end=false;
    while (!end) {
      final Value<?> val=readValueRec();
      if (val == BVOID) {
        end=true;
      }
 else {
        list.add(val);
      }
    }
    return new ListValue(list);
  }
 else   if (first == DICTIONARY_VALUE) {
    final SortedMap<String,Value<?>> map=new TreeMap<String,Value<?>>();
    String lastKeyStr=null;
    boolean end=false;
    while (!end) {
      final Value<?> key=readValueRec();
      if (key != BVOID && !(key instanceof StringValue)) {
        throw new IOException("String_Node_Str");
      }
      if (key == BVOID) {
        end=true;
      }
 else {
        final String currKeyStr=((StringValue)key).getStringValue();
        if (lastKeyStr != null) {
          final int cmp=lastKeyStr.compareTo(currKeyStr);
          if (cmp > 0) {
            throw new IOException("String_Node_Str");
          }
 else           if (cmp == 0) {
            throw new IOException("String_Node_Str");
          }
        }
        lastKeyStr=currKeyStr;
        final Value<?> val=readValueRec();
        if (val == null) {
          throw new IOException("String_Node_Str");
        }
        map.put(new String((byte[])key.getValue(),Bencode.UTF8),val);
      }
    }
    return new DictionaryValue(map);
  }
 else   if (first >= STRING_VALUE_FROM && first <= STRING_VALUE_TO) {
    charBuffer[0]=(char)first;
    int i=1;
    boolean end=false;
    while (!end) {
      final int readInt=stream.read();
      if (readInt < 0) {
        throw new EOFException();
      }
 else       if (readInt == ':') {
        end=true;
      }
 else       if (readInt >= '0' && readInt <= '9') {
        charBuffer[i]=(char)readInt;
        i++;
      }
 else {
        throw new IOException("String_Node_Str");
      }
    }
    final long lsize=Long.parseLong(new String(charBuffer,0,i));
    if (lsize > Integer.MAX_VALUE) {
      throw new IOException("String_Node_Str");
    }
    final int size=(int)lsize;
    if (byteBuffer.length < lsize) {
      byteBuffer=new byte[Math.max(size + 1,byteBuffer.length * 2 + 1)];
    }
    final int howMany=stream.read(byteBuffer,0,size);
    if (howMany != size) {
      throw new EOFException();
    }
    return new StringValue(Arrays.copyOf(byteBuffer,size));
  }
 else {
    if (first == -1) {
      return null;
    }
 else {
      throw new IOException("String_Node_Str" + Integer.toHexString(first));
    }
  }
}