Program: 110390
Project: 110390
Buggy source:
public synchronized void commitSample(long timeUs,int sampleFlags,long offset,int size,byte[] encryptionKey,Format format){
  timesUs[relativeWriteIndex]=timeUs;
  offsets[relativeWriteIndex]=offset;
  sizes[relativeWriteIndex]=size;
  flags[relativeWriteIndex]=sampleFlags;
  encryptionKeys[relativeWriteIndex]=encryptionKey;
  formats[relativeWriteIndex]=format;
  largestQueuedTimestampUs=Math.max(largestQueuedTimestampUs,timeUs);
  queueSize++;
  if (queueSize == capacity) {
    int newCapacity=capacity + SAMPLE_CAPACITY_INCREMENT;
    long[] newOffsets=new long[newCapacity];
    long[] newTimesUs=new long[newCapacity];
    int[] newFlags=new int[newCapacity];
    int[] newSizes=new int[newCapacity];
    byte[][] newEncryptionKeys=new byte[newCapacity][];
    Format[] newFormats=new Format[newCapacity];
    int beforeWrap=capacity - relativeReadIndex;
    System.arraycopy(offsets,relativeReadIndex,newOffsets,0,beforeWrap);
    System.arraycopy(timesUs,relativeReadIndex,newTimesUs,0,beforeWrap);
    System.arraycopy(flags,relativeReadIndex,newFlags,0,beforeWrap);
    System.arraycopy(sizes,relativeReadIndex,newSizes,0,beforeWrap);
    System.arraycopy(encryptionKeys,relativeReadIndex,newEncryptionKeys,0,beforeWrap);
    System.arraycopy(formats,relativeReadIndex,newFormats,0,beforeWrap);
    int afterWrap=relativeReadIndex;
    System.arraycopy(offsets,0,newOffsets,beforeWrap,afterWrap);
    System.arraycopy(timesUs,0,newTimesUs,beforeWrap,afterWrap);
    System.arraycopy(flags,0,newFlags,beforeWrap,afterWrap);
    System.arraycopy(sizes,0,newSizes,beforeWrap,afterWrap);
    System.arraycopy(encryptionKeys,0,newEncryptionKeys,beforeWrap,afterWrap);
    System.arraycopy(formats,0,newFormats,beforeWrap,afterWrap);
    offsets=newOffsets;
    timesUs=newTimesUs;
    flags=newFlags;
    sizes=newSizes;
    encryptionKeys=newEncryptionKeys;
    formats=newFormats;
    relativeReadIndex=0;
    relativeWriteIndex=capacity;
    queueSize=capacity;
    capacity=newCapacity;
  }
 else {
    relativeWriteIndex++;
    if (relativeWriteIndex == capacity) {
      relativeWriteIndex=0;
    }
  }
}

Fixed version (ground truth):
public synchronized void commitSample(long timeUs,int sampleFlags,long offset,int size,byte[] encryptionKey){
  timesUs[relativeWriteIndex]=timeUs;
  offsets[relativeWriteIndex]=offset;
  sizes[relativeWriteIndex]=size;
  flags[relativeWriteIndex]=sampleFlags;
  encryptionKeys[relativeWriteIndex]=encryptionKey;
  formats[relativeWriteIndex]=upstreamFormat;
  largestQueuedTimestampUs=Math.max(largestQueuedTimestampUs,timeUs);
  queueSize++;
  if (queueSize == capacity) {
    int newCapacity=capacity + SAMPLE_CAPACITY_INCREMENT;
    long[] newOffsets=new long[newCapacity];
    long[] newTimesUs=new long[newCapacity];
    int[] newFlags=new int[newCapacity];
    int[] newSizes=new int[newCapacity];
    byte[][] newEncryptionKeys=new byte[newCapacity][];
    Format[] newFormats=new Format[newCapacity];
    int beforeWrap=capacity - relativeReadIndex;
    System.arraycopy(offsets,relativeReadIndex,newOffsets,0,beforeWrap);
    System.arraycopy(timesUs,relativeReadIndex,newTimesUs,0,beforeWrap);
    System.arraycopy(flags,relativeReadIndex,newFlags,0,beforeWrap);
    System.arraycopy(sizes,relativeReadIndex,newSizes,0,beforeWrap);
    System.arraycopy(encryptionKeys,relativeReadIndex,newEncryptionKeys,0,beforeWrap);
    System.arraycopy(formats,relativeReadIndex,newFormats,0,beforeWrap);
    int afterWrap=relativeReadIndex;
    System.arraycopy(offsets,0,newOffsets,beforeWrap,afterWrap);
    System.arraycopy(timesUs,0,newTimesUs,beforeWrap,afterWrap);
    System.arraycopy(flags,0,newFlags,beforeWrap,afterWrap);
    System.arraycopy(sizes,0,newSizes,beforeWrap,afterWrap);
    System.arraycopy(encryptionKeys,0,newEncryptionKeys,beforeWrap,afterWrap);
    System.arraycopy(formats,0,newFormats,beforeWrap,afterWrap);
    offsets=newOffsets;
    timesUs=newTimesUs;
    flags=newFlags;
    sizes=newSizes;
    encryptionKeys=newEncryptionKeys;
    formats=newFormats;
    relativeReadIndex=0;
    relativeWriteIndex=capacity;
    queueSize=capacity;
    capacity=newCapacity;
  }
 else {
    relativeWriteIndex++;
    if (relativeWriteIndex == capacity) {
      relativeWriteIndex=0;
    }
  }
}