Program: 43030
Project: 43030
Buggy source:
private Descriptor readClassDescriptor(int leadByte) throws IOException, ClassNotFoundException {
switch (leadByte) {
case TC_CLASSDESC:
{
      final String className=readUTF();
      final long svu=readLong();
      final int idx=instanceCache.size();
      instanceCache.add(null);
      final int descFlags=readUnsignedByte();
      final int fieldCount=readUnsignedShort();
      final int[] typecodes=new int[fieldCount];
      final String[] names=new String[fieldCount];
      final String[] fieldSignatures=new String[fieldCount];
      for (int i=0; i < fieldCount; i++) {
        typecodes[i]=readUnsignedByte();
        names[i]=readUTF();
        if (typecodes[i] == '[' || typecodes[i] == 'L') {
          fieldSignatures[i]=doReadString();
        }
      }
      final Class<?> clazz=classResolver.resolveClass(blockUnmarshaller,className,svu);
      blockUnmarshaller.readToEndBlockData();
      final SerializableClass sc=registry.lookup(clazz);
      final SerializableField[] fields=new SerializableField[fieldCount];
      for (int i=0; i < fieldCount; i++) {
        final Class<?> fieldType;
switch (typecodes[i]) {
case 'B':
{
            fieldType=byte.class;
            break;
          }
case 'C':
{
          fieldType=char.class;
          break;
        }
case 'D':
{
        fieldType=double.class;
        break;
      }
case 'F':
{
      fieldType=float.class;
      break;
    }
case 'I':
{
    fieldType=int.class;
    break;
  }
case 'J':
{
  fieldType=long.class;
  break;
}
case 'S':
{
fieldType=short.class;
break;
}
case 'Z':
{
fieldType=boolean.class;
break;
}
case 'L':
case '[':
{
fieldType=Object.class;
break;
}
default :
{
throw new StreamCorruptedException("String_Node_Str" + typecodes[i]);
}
}
fields[i]=sc.getSerializableField(names[i],fieldType,false);
}
final Descriptor superDescr=readClassDescriptor();
final Class<?> superClazz=clazz.getSuperclass();
final Descriptor descriptor;
if (superDescr == null || superDescr.getType().isAssignableFrom(superClazz)) {
descriptor=descFlags == 0 ? new NoDataDescriptor(clazz,bridge(superDescr,superClazz)) : new PlainDescriptor(clazz,bridge(superDescr,superClazz),fields,descFlags);
}
 else {
throw new InvalidClassException(clazz.getName(),"String_Node_Str");
}
instanceCache.set(idx,descriptor);
return descriptor;
}
case TC_PROXYCLASSDESC:
{
final int idx=instanceCache.size();
instanceCache.add(UNRESOLVED);
final int cnt=readInt();
final String[] interfaces=new String[cnt];
for (int i=0; i < interfaces.length; i++) {
interfaces[i]=readUTF();
}
final Class<?> clazz=classResolver.resolveProxyClass(blockUnmarshaller,interfaces);
blockUnmarshaller.readToEndBlockData();
final Descriptor superDescr=readClassDescriptor();
final ProxyDescriptor descr=new ProxyDescriptor(clazz,superDescr,interfaces);
instanceCache.set(idx,descr);
return descr;
}
case TC_NULL:
{
return null;
}
case TC_REFERENCE:
{
try {
return (Descriptor)readBackReference(readInt());
}
 catch (ClassCastException e) {
throw new StreamCorruptedException("String_Node_Str");
}
}
default :
throw badLeadByte(leadByte);
}
}

Fixed version (ground truth):
private Descriptor readClassDescriptor(int leadByte) throws IOException, ClassNotFoundException {
switch (leadByte) {
case TC_CLASSDESC:
{
      final String className=readUTF();
      final long svu=readLong();
      final int idx=instanceCache.size();
      instanceCache.add(null);
      final int descFlags=readUnsignedByte();
      final int fieldCount=readUnsignedShort();
      final int[] typecodes=new int[fieldCount];
      final String[] names=new String[fieldCount];
      final String[] fieldSignatures=new String[fieldCount];
      for (int i=0; i < fieldCount; i++) {
        typecodes[i]=readUnsignedByte();
        names[i]=readUTF();
        if (typecodes[i] == '[' || typecodes[i] == 'L') {
          fieldSignatures[i]=doReadString();
        }
      }
      final Class<?> clazz=classResolver.resolveClass(blockUnmarshaller,className,svu);
      blockUnmarshaller.readToEndBlockData();
      blockUnmarshaller.unblock();
      final SerializableClass sc=registry.lookup(clazz);
      final SerializableField[] fields=new SerializableField[fieldCount];
      for (int i=0; i < fieldCount; i++) {
        final Class<?> fieldType;
switch (typecodes[i]) {
case 'B':
{
            fieldType=byte.class;
            break;
          }
case 'C':
{
          fieldType=char.class;
          break;
        }
case 'D':
{
        fieldType=double.class;
        break;
      }
case 'F':
{
      fieldType=float.class;
      break;
    }
case 'I':
{
    fieldType=int.class;
    break;
  }
case 'J':
{
  fieldType=long.class;
  break;
}
case 'S':
{
fieldType=short.class;
break;
}
case 'Z':
{
fieldType=boolean.class;
break;
}
case 'L':
case '[':
{
fieldType=Object.class;
break;
}
default :
{
throw new StreamCorruptedException("String_Node_Str" + typecodes[i]);
}
}
fields[i]=sc.getSerializableField(names[i],fieldType,false);
}
final Descriptor superDescr=readClassDescriptor();
final Class<?> superClazz=clazz.getSuperclass();
final Descriptor descriptor;
if (superDescr == null || superDescr.getType().isAssignableFrom(superClazz)) {
descriptor=descFlags == 0 ? new NoDataDescriptor(clazz,bridge(superDescr,superClazz)) : new PlainDescriptor(clazz,bridge(superDescr,superClazz),fields,descFlags);
}
 else {
throw new InvalidClassException(clazz.getName(),"String_Node_Str");
}
instanceCache.set(idx,descriptor);
return descriptor;
}
case TC_PROXYCLASSDESC:
{
final int idx=instanceCache.size();
instanceCache.add(UNRESOLVED);
final int cnt=readInt();
final String[] interfaces=new String[cnt];
for (int i=0; i < interfaces.length; i++) {
interfaces[i]=readUTF();
}
final Class<?> clazz=classResolver.resolveProxyClass(blockUnmarshaller,interfaces);
blockUnmarshaller.readToEndBlockData();
blockUnmarshaller.unblock();
final Descriptor superDescr=readClassDescriptor();
final ProxyDescriptor descr=new ProxyDescriptor(clazz,superDescr,interfaces);
instanceCache.set(idx,descr);
return descr;
}
case TC_NULL:
{
return null;
}
case TC_REFERENCE:
{
try {
return (Descriptor)readBackReference(readInt());
}
 catch (ClassCastException e) {
throw new StreamCorruptedException("String_Node_Str");
}
}
default :
throw badLeadByte(leadByte);
}
}