Program: 156215
Project: 156215
Buggy source:
private List<Position> parseLocation(Channel channel,ChannelBuffer buf){
  List<Position> positions=new LinkedList<Position>();
  buf.skipBytes(4);
  buf.readUnsignedInt();
  int codec=buf.readUnsignedByte();
  if (codec == CODEC_12) {
    return null;
  }
  int count=buf.readUnsignedByte();
  for (int i=0; i < count; i++) {
    Position position=new Position();
    position.setProtocol(getProtocol());
    position.setDeviceId(deviceId);
    int globalMask=0x0f;
    if (codec == CODEC_GH3000) {
      long time=buf.readUnsignedInt() & 0x3fffffff;
      time+=1167609600;
      position.setTime(new Date(time * 1000));
      globalMask=buf.readUnsignedByte();
      if (!checkBit(globalMask,0)) {
        return null;
      }
      int locationMask=buf.readUnsignedByte();
      if (checkBit(locationMask,0)) {
        position.setLatitude(Double.valueOf(buf.readFloat()));
        position.setLongitude(Double.valueOf(buf.readFloat()));
      }
      if (checkBit(locationMask,1)) {
        position.setAltitude(buf.readUnsignedShort());
      }
      if (checkBit(locationMask,2)) {
        position.setCourse(buf.readUnsignedByte() * 360.0 / 256);
      }
      if (checkBit(locationMask,3)) {
        position.setSpeed(buf.readUnsignedByte() * 0.539957);
      }
      if (checkBit(locationMask,4)) {
        int satellites=buf.readUnsignedByte();
        position.set("String_Node_Str",satellites);
        position.setValid(satellites >= 3);
      }
      if (checkBit(locationMask,5)) {
        position.set("String_Node_Str",buf.readUnsignedShort());
        position.set("String_Node_Str",buf.readUnsignedShort());
      }
      if (checkBit(locationMask,6)) {
        position.set("String_Node_Str",buf.readUnsignedByte());
      }
      if (checkBit(locationMask,7)) {
        position.set("String_Node_Str",buf.readUnsignedInt());
      }
    }
 else {
      position.setTime(new Date(buf.readLong()));
      position.set("String_Node_Str",buf.readUnsignedByte());
      position.setLongitude(buf.readInt() / 10000000.0);
      position.setLatitude(buf.readInt() / 10000000.0);
      position.setAltitude(buf.readShort());
      position.setCourse(buf.readUnsignedShort());
      int satellites=buf.readUnsignedByte();
      position.set("String_Node_Str",satellites);
      position.setValid(satellites != 0);
      position.setSpeed(buf.readUnsignedShort() * 0.539957);
      position.set("String_Node_Str",buf.readUnsignedByte());
      buf.readUnsignedByte();
    }
    if (checkBit(globalMask,1)) {
      int cnt=buf.readUnsignedByte();
      for (int j=0; j < cnt; j++) {
        int id=buf.readUnsignedByte();
        if (id == 1) {
          position.set("String_Node_Str",buf.readUnsignedByte());
        }
 else {
          position.set("String_Node_Str" + id,buf.readUnsignedByte());
        }
      }
    }
    if (checkBit(globalMask,2)) {
      int cnt=buf.readUnsignedByte();
      for (int j=0; j < cnt; j++) {
        position.set("String_Node_Str" + buf.readUnsignedByte(),buf.readUnsignedShort());
      }
    }
    if (checkBit(globalMask,3)) {
      int cnt=buf.readUnsignedByte();
      for (int j=0; j < cnt; j++) {
        position.set("String_Node_Str" + buf.readUnsignedByte(),buf.readUnsignedInt());
      }
    }
    if (codec == CODEC_FM4X00) {
      int cnt=buf.readUnsignedByte();
      for (int j=0; j < cnt; j++) {
        position.set("String_Node_Str" + buf.readUnsignedByte(),buf.readLong());
      }
    }
    positions.add(position);
  }
  if (channel != null) {
    ChannelBuffer response=ChannelBuffers.directBuffer(4);
    response.writeInt(count);
    channel.write(response);
  }
  return positions;
}

Fixed version (ground truth):
private List<Position> parseLocation(Channel channel,ChannelBuffer buf){
  List<Position> positions=new LinkedList<Position>();
  buf.skipBytes(4);
  buf.readUnsignedInt();
  int codec=buf.readUnsignedByte();
  if (codec == CODEC_12) {
    return null;
  }
  int count=buf.readUnsignedByte();
  for (int i=0; i < count; i++) {
    Position position=new Position();
    position.setProtocol(getProtocol());
    position.setDeviceId(getDeviceId());
    int globalMask=0x0f;
    if (codec == CODEC_GH3000) {
      long time=buf.readUnsignedInt() & 0x3fffffff;
      time+=1167609600;
      position.setTime(new Date(time * 1000));
      globalMask=buf.readUnsignedByte();
      if (!checkBit(globalMask,0)) {
        return null;
      }
      int locationMask=buf.readUnsignedByte();
      if (checkBit(locationMask,0)) {
        position.setLatitude(buf.readFloat());
        position.setLongitude(buf.readFloat());
      }
      if (checkBit(locationMask,1)) {
        position.setAltitude(buf.readUnsignedShort());
      }
      if (checkBit(locationMask,2)) {
        position.setCourse(buf.readUnsignedByte() * 360.0 / 256);
      }
      if (checkBit(locationMask,3)) {
        position.setSpeed(buf.readUnsignedByte() * 0.539957);
      }
      if (checkBit(locationMask,4)) {
        int satellites=buf.readUnsignedByte();
        position.set("String_Node_Str",satellites);
        position.setValid(satellites >= 3);
      }
      if (checkBit(locationMask,5)) {
        position.set("String_Node_Str",buf.readUnsignedShort());
        position.set("String_Node_Str",buf.readUnsignedShort());
      }
      if (checkBit(locationMask,6)) {
        position.set("String_Node_Str",buf.readUnsignedByte());
      }
      if (checkBit(locationMask,7)) {
        position.set("String_Node_Str",buf.readUnsignedInt());
      }
    }
 else {
      position.setTime(new Date(buf.readLong()));
      position.set("String_Node_Str",buf.readUnsignedByte());
      position.setLongitude(buf.readInt() / 10000000.0);
      position.setLatitude(buf.readInt() / 10000000.0);
      position.setAltitude(buf.readShort());
      position.setCourse(buf.readUnsignedShort());
      int satellites=buf.readUnsignedByte();
      position.set("String_Node_Str",satellites);
      position.setValid(satellites != 0);
      position.setSpeed(buf.readUnsignedShort() * 0.539957);
      position.set("String_Node_Str",buf.readUnsignedByte());
      buf.readUnsignedByte();
    }
    if (checkBit(globalMask,1)) {
      int cnt=buf.readUnsignedByte();
      for (int j=0; j < cnt; j++) {
        int id=buf.readUnsignedByte();
        if (id == 1) {
          position.set("String_Node_Str",buf.readUnsignedByte());
        }
 else {
          position.set("String_Node_Str" + id,buf.readUnsignedByte());
        }
      }
    }
    if (checkBit(globalMask,2)) {
      int cnt=buf.readUnsignedByte();
      for (int j=0; j < cnt; j++) {
        position.set("String_Node_Str" + buf.readUnsignedByte(),buf.readUnsignedShort());
      }
    }
    if (checkBit(globalMask,3)) {
      int cnt=buf.readUnsignedByte();
      for (int j=0; j < cnt; j++) {
        position.set("String_Node_Str" + buf.readUnsignedByte(),buf.readUnsignedInt());
      }
    }
    if (codec == CODEC_FM4X00) {
      int cnt=buf.readUnsignedByte();
      for (int j=0; j < cnt; j++) {
        position.set("String_Node_Str" + buf.readUnsignedByte(),buf.readLong());
      }
    }
    positions.add(position);
  }
  if (channel != null) {
    ChannelBuffer response=ChannelBuffers.directBuffer(4);
    response.writeInt(count);
    channel.write(response);
  }
  return positions;
}