Program: 55672
Project: 55672
Buggy source:
/** 
 * Updates the binary representation of the data, such that it reflects the state of the currently stored fields. If the binary representation is already up to date, nothing happens. Otherwise, this function triggers the modified fields to serialize themselves into the records buffer and afterwards updates the offset table.
 */
public void updateBinaryRepresenation(){
  if (!this.modified)   return;
  final int firstModified=this.firstModifiedPos;
  final int numFields=this.numFields;
  final int[] offsets=this.offsets;
  if (this.serializer == null) {
    this.serializer=new InternalDeSerializer();
  }
  final InternalDeSerializer serializer=this.serializer;
  if (numFields > 0) {
    int offset=firstModified <= 0 ? 0 : this.offsets[firstModified - 1] + this.lengths[firstModified - 1];
    serializer.position=offset;
    if (firstModified > 0) {
      serializer.memory=this.binaryData == null ? new byte[numFields * DEFAULT_FIELD_LEN] : this.binaryData;
      try {
        for (int i=firstModified; i < numFields; i++) {
          if (offsets[i] == NULL_INDICATOR_OFFSET)           continue;
          offsets[i]=offset;
          this.fields[i].write(serializer);
          int newOffset=serializer.position;
          this.lengths[i]=newOffset - offset;
          offset=newOffset;
        }
      }
 catch (      Exception e) {
        throw new RuntimeException("String_Node_Str" + e.getMessage());
      }
    }
 else {
      serializer.memory=this.serializationSwitchBuffer == null ? new byte[numFields * DEFAULT_FIELD_LEN] : this.serializationSwitchBuffer;
      if (offset > 0 & this.binaryData != null) {
        System.arraycopy(this.binaryData,0,serializer.memory,0,offset);
      }
      try {
        for (int i=firstModified; i < numFields; i++) {
          final int co=offsets[i];
          if (co == NULL_INDICATOR_OFFSET)           continue;
          offsets[i]=offset;
          if (co == MODIFIED_INDICATOR_OFFSET)           this.fields[i].write(serializer);
 else           serializer.write(this.binaryData,co,this.lengths[i]);
          this.lengths[i]=serializer.position - offset;
          offset=serializer.position;
        }
      }
 catch (      Exception e) {
        throw new RuntimeException("String_Node_Str" + e.getMessage());
      }
      this.serializationSwitchBuffer=this.binaryData;
      this.binaryData=serializer.memory;
    }
  }
  try {
    int slp=serializer.position;
    if (numFields <= 8) {
      int mask=0;
      for (int i=numFields - 1; i > 0; i--) {
        mask<<=1;
        if (offsets[i] != NULL_INDICATOR_OFFSET) {
          slp=serializer.position;
          serializer.writeValLenIntBackwards(offsets[i]);
          mask|=0x1;
        }
      }
      mask<<=1;
      if (offsets[0] != NULL_INDICATOR_OFFSET) {
        mask|=0x1;
      }
 else {
        serializer.position=slp;
      }
      serializer.writeByte(mask);
    }
 else {
      for (int i=numFields - 1; i > 0; i--) {
        if (offsets[i] != NULL_INDICATOR_OFFSET) {
          slp=serializer.position;
          serializer.writeValLenIntBackwards(offsets[i]);
        }
      }
      if (offsets[0] == NULL_INDICATOR_OFFSET) {
        serializer.position=slp;
      }
      int col=numFields - 1;
      int mask=0;
      for (int i=numFields & 0x7; i > 0; i--, col--) {
        mask<<=1;
        mask|=(offsets[col] != NULL_INDICATOR_OFFSET) ? 0x1 : 0x0;
      }
      serializer.writeByte(mask);
      for (int i=numFields >>> 3; i > 0; i--) {
        mask=0;
        for (int k=0; k < 8; k++, col--) {
          mask<<=1;
          mask|=(offsets[col] != NULL_INDICATOR_OFFSET) ? 0x1 : 0x0;
        }
        serializer.writeByte(mask);
      }
    }
    serializer.writeValLenIntBackwards(numFields);
  }
 catch (  Exception e) {
    throw new RuntimeException("String_Node_Str" + e.getMessage(),e);
  }
  this.binaryData=serializer.memory;
  this.binaryLen=serializer.position;
  this.firstModifiedPos=Integer.MAX_VALUE;
  this.modified=false;
}

Fixed version (ground truth):
/** 
 * Updates the binary representation of the data, such that it reflects the state of the currently stored fields. If the binary representation is already up to date, nothing happens. Otherwise, this function triggers the modified fields to serialize themselves into the records buffer and afterwards updates the offset table.
 */
public void updateBinaryRepresenation(){
  if (!this.modified)   return;
  final int firstModified=this.firstModifiedPos;
  final int numFields=this.numFields;
  final int[] offsets=this.offsets;
  if (this.serializer == null) {
    this.serializer=new InternalDeSerializer();
  }
  final InternalDeSerializer serializer=this.serializer;
  if (numFields > 0) {
    int offset=0;
    if (firstModified > 0) {
      for (int i=firstModified - 1; i >= 0; i--) {
        if (this.offsets[i] != NULL_INDICATOR_OFFSET) {
          offset=this.offsets[i] + this.lengths[i];
          break;
        }
      }
    }
    serializer.position=offset;
    if (firstModified > 0) {
      serializer.memory=this.binaryData == null ? new byte[numFields * DEFAULT_FIELD_LEN] : this.binaryData;
      try {
        for (int i=firstModified; i < numFields; i++) {
          if (offsets[i] == NULL_INDICATOR_OFFSET)           continue;
          offsets[i]=offset;
          this.fields[i].write(serializer);
          int newOffset=serializer.position;
          this.lengths[i]=newOffset - offset;
          offset=newOffset;
        }
      }
 catch (      Exception e) {
        throw new RuntimeException("String_Node_Str" + e.getMessage());
      }
    }
 else {
      serializer.memory=this.serializationSwitchBuffer == null ? new byte[numFields * DEFAULT_FIELD_LEN] : this.serializationSwitchBuffer;
      if (offset > 0 & this.binaryData != null) {
        System.arraycopy(this.binaryData,0,serializer.memory,0,offset);
      }
      try {
        for (int i=firstModified; i < numFields; i++) {
          final int co=offsets[i];
          if (co == NULL_INDICATOR_OFFSET)           continue;
          offsets[i]=offset;
          if (co == MODIFIED_INDICATOR_OFFSET)           this.fields[i].write(serializer);
 else           serializer.write(this.binaryData,co,this.lengths[i]);
          this.lengths[i]=serializer.position - offset;
          offset=serializer.position;
        }
      }
 catch (      Exception e) {
        throw new RuntimeException("String_Node_Str" + e.getMessage());
      }
      this.serializationSwitchBuffer=this.binaryData;
      this.binaryData=serializer.memory;
    }
  }
  try {
    int slp=serializer.position;
    if (numFields <= 8) {
      int mask=0;
      for (int i=numFields - 1; i > 0; i--) {
        mask<<=1;
        if (offsets[i] != NULL_INDICATOR_OFFSET) {
          slp=serializer.position;
          serializer.writeValLenIntBackwards(offsets[i]);
          mask|=0x1;
        }
      }
      mask<<=1;
      if (offsets[0] != NULL_INDICATOR_OFFSET) {
        mask|=0x1;
      }
 else {
        serializer.position=slp;
      }
      serializer.writeByte(mask);
    }
 else {
      for (int i=numFields - 1; i > 0; i--) {
        if (offsets[i] != NULL_INDICATOR_OFFSET) {
          slp=serializer.position;
          serializer.writeValLenIntBackwards(offsets[i]);
        }
      }
      if (offsets[0] == NULL_INDICATOR_OFFSET) {
        serializer.position=slp;
      }
      int col=numFields - 1;
      int mask=0;
      for (int i=numFields & 0x7; i > 0; i--, col--) {
        mask<<=1;
        mask|=(offsets[col] != NULL_INDICATOR_OFFSET) ? 0x1 : 0x0;
      }
      serializer.writeByte(mask);
      for (int i=numFields >>> 3; i > 0; i--) {
        mask=0;
        for (int k=0; k < 8; k++, col--) {
          mask<<=1;
          mask|=(offsets[col] != NULL_INDICATOR_OFFSET) ? 0x1 : 0x0;
        }
        serializer.writeByte(mask);
      }
    }
    serializer.writeValLenIntBackwards(numFields);
  }
 catch (  Exception e) {
    throw new RuntimeException("String_Node_Str" + e.getMessage(),e);
  }
  this.binaryData=serializer.memory;
  this.binaryLen=serializer.position;
  this.firstModifiedPos=Integer.MAX_VALUE;
  this.modified=false;
}