Program: 110173
Project: 110173
Buggy source:
@Override public boolean read(ExtractorInput input) throws IOException, InterruptedException {
  Assertions.checkState(output != null);
  while (true) {
    if (!masterElementsStack.isEmpty() && input.getPosition() >= masterElementsStack.peek().elementEndPosition) {
      output.endMasterElement(masterElementsStack.pop().elementId);
      return true;
    }
    if (elementState == ELEMENT_STATE_READ_ID) {
      long result=varintReader.readUnsignedVarint(input,true,false,MAX_ID_BYTES);
      if (result == C.RESULT_MAX_LENGTH_EXCEEDED) {
        result=maybeResyncToNextLevel1Element(input);
      }
      if (result == C.RESULT_END_OF_INPUT) {
        return false;
      }
      elementId=(int)result;
      elementState=ELEMENT_STATE_READ_CONTENT_SIZE;
    }
    if (elementState == ELEMENT_STATE_READ_CONTENT_SIZE) {
      elementContentSize=varintReader.readUnsignedVarint(input,false,true,MAX_LENGTH_BYTES);
      elementState=ELEMENT_STATE_READ_CONTENT;
    }
    @EbmlReaderOutput.ElementType int type=output.getElementType(elementId);
switch (type) {
case EbmlReaderOutput.TYPE_MASTER:
      long elementContentPosition=input.getPosition();
    long elementEndPosition=elementContentPosition + elementContentSize;
  masterElementsStack.add(new MasterElement(elementId,elementEndPosition));
output.startMasterElement(elementId,elementContentPosition,elementContentSize);
elementState=ELEMENT_STATE_READ_ID;
return true;
case EbmlReaderOutput.TYPE_UNSIGNED_INT:
if (elementContentSize > MAX_INTEGER_ELEMENT_SIZE_BYTES) {
throw new ParserException("String_Node_Str" + elementContentSize);
}
output.integerElement(elementId,readInteger(input,(int)elementContentSize));
elementState=ELEMENT_STATE_READ_ID;
return true;
case EbmlReaderOutput.TYPE_FLOAT:
if (elementContentSize != VALID_FLOAT32_ELEMENT_SIZE_BYTES && elementContentSize != VALID_FLOAT64_ELEMENT_SIZE_BYTES) {
throw new ParserException("String_Node_Str" + elementContentSize);
}
output.floatElement(elementId,readFloat(input,(int)elementContentSize));
elementState=ELEMENT_STATE_READ_ID;
return true;
case EbmlReaderOutput.TYPE_STRING:
if (elementContentSize > Integer.MAX_VALUE) {
throw new ParserException("String_Node_Str" + elementContentSize);
}
output.stringElement(elementId,readString(input,(int)elementContentSize));
elementState=ELEMENT_STATE_READ_ID;
return true;
case EbmlReaderOutput.TYPE_BINARY:
output.binaryElement(elementId,(int)elementContentSize,input);
elementState=ELEMENT_STATE_READ_ID;
return true;
case EbmlReaderOutput.TYPE_UNKNOWN:
input.skipFully((int)elementContentSize);
elementState=ELEMENT_STATE_READ_ID;
break;
default :
throw new ParserException("String_Node_Str" + type);
}
}
}

Fixed version (ground truth):
@Override public boolean read(ExtractorInput input) throws IOException, InterruptedException {
  Assertions.checkState(output != null);
  while (true) {
    if (!masterElementsStack.isEmpty() && input.getPosition() >= masterElementsStack.peek().elementEndPosition) {
      output.endMasterElement(masterElementsStack.pop().elementId);
      return true;
    }
    if (elementState == ELEMENT_STATE_READ_ID) {
      long result=varintReader.readUnsignedVarint(input,true,false,MAX_ID_BYTES);
      if (result == C.RESULT_MAX_LENGTH_EXCEEDED) {
        result=maybeResyncToNextLevel1Element(input);
      }
      if (result == C.RESULT_END_OF_INPUT) {
        return false;
      }
      elementId=(int)result;
      elementState=ELEMENT_STATE_READ_CONTENT_SIZE;
    }
    if (elementState == ELEMENT_STATE_READ_CONTENT_SIZE) {
      elementContentSize=varintReader.readUnsignedVarint(input,false,true,MAX_LENGTH_BYTES);
      elementState=ELEMENT_STATE_READ_CONTENT;
    }
    @EbmlReaderOutput.ElementType int type=output.getElementType(elementId);
switch (type) {
case EbmlReaderOutput.TYPE_MASTER:
      long elementContentPosition=input.getPosition();
    long elementEndPosition=elementContentPosition + elementContentSize;
  masterElementsStack.push(new MasterElement(elementId,elementEndPosition));
output.startMasterElement(elementId,elementContentPosition,elementContentSize);
elementState=ELEMENT_STATE_READ_ID;
return true;
case EbmlReaderOutput.TYPE_UNSIGNED_INT:
if (elementContentSize > MAX_INTEGER_ELEMENT_SIZE_BYTES) {
throw new ParserException("String_Node_Str" + elementContentSize);
}
output.integerElement(elementId,readInteger(input,(int)elementContentSize));
elementState=ELEMENT_STATE_READ_ID;
return true;
case EbmlReaderOutput.TYPE_FLOAT:
if (elementContentSize != VALID_FLOAT32_ELEMENT_SIZE_BYTES && elementContentSize != VALID_FLOAT64_ELEMENT_SIZE_BYTES) {
throw new ParserException("String_Node_Str" + elementContentSize);
}
output.floatElement(elementId,readFloat(input,(int)elementContentSize));
elementState=ELEMENT_STATE_READ_ID;
return true;
case EbmlReaderOutput.TYPE_STRING:
if (elementContentSize > Integer.MAX_VALUE) {
throw new ParserException("String_Node_Str" + elementContentSize);
}
output.stringElement(elementId,readString(input,(int)elementContentSize));
elementState=ELEMENT_STATE_READ_ID;
return true;
case EbmlReaderOutput.TYPE_BINARY:
output.binaryElement(elementId,(int)elementContentSize,input);
elementState=ELEMENT_STATE_READ_ID;
return true;
case EbmlReaderOutput.TYPE_UNKNOWN:
input.skipFully((int)elementContentSize);
elementState=ELEMENT_STATE_READ_ID;
break;
default :
throw new ParserException("String_Node_Str" + type);
}
}
}