nus-yam/ex-repair huggingface dataset:
Program: 5610
Project: 5610
Buggy source:
private boolean isForMe(byte[] address){
  IPv6Packet.printAddress(System.out,address);
  if (Utils.equals(myIPAddress,address) || Utils.equals(myLocalIPAddress,address) || Utils.equals(myLocalSolicited,address))   return true;
  if (isRouter && Utils.equals(ALL_ROUTERS,address))   return true;
  if (Utils.equals(ALL_NODES,address))   return true;
  if (Utils.equals(UNSPECIFIED,address))   return true;
  return false;
}

Fixed version (ground truth):
private boolean isForMe(byte[] address){
  if (Utils.equals(myIPAddress,address) || Utils.equals(myLocalIPAddress,address) || Utils.equals(myLocalSolicited,address))   return true;
  if (isRouter && Utils.equals(ALL_ROUTERS,address))   return true;
  if (Utils.equals(ALL_NODES,address))   return true;
  if (Utils.equals(UNSPECIFIED,address))   return true;
  return false;
}
Program: 5611
Project: 5611
Buggy source:
void receive(TCPPacket tcpPacket){
  int plen=tcpPacket.payload == null ? 0 : tcpPacket.payload.length;
  receiveNext=tcpPacket.seqNo + plen;
  if (tcpPacket.isAck()) {
    if (sendNext == tcpPacket.ackNo) {
      sentUnack=tcpPacket.ackNo;
    }
 else {
      System.out.println("String_Node_Str" + Integer.toString(tcpPacket.ackNo,16) + "String_Node_Str"+ Integer.toString(sendNext,16));
    }
  }
  if (receiveNext == tcpPacket.seqNo) {
  }
 else {
    System.out.println("String_Node_Str" + receiveNext + "String_Node_Str"+ tcpPacket.seqNo);
  }
  if (tcpPacket.isFin()) {
    if (tcpListener != null && plen > 0) {
      tcpListener.connectionClosed(this);
    }
  }
  TCPPacket tcpReply=TCPHandler.createAck(tcpPacket,0);
  tcpReply.ackNo=tcpPacket.seqNo + plen;
  tcpReply.seqNo=sendNext;
  send(tcpReply);
  if (plen > 0)   if (tcpListener != null) {
    tcpListener.tcpDataReceived(this,tcpPacket);
  }
}

Fixed version (ground truth):
void receive(TCPPacket tcpPacket){
  int plen=tcpPacket.payload == null ? 0 : tcpPacket.payload.length;
  if (tcpPacket.isAck()) {
    if (sendNext == tcpPacket.ackNo) {
      sentUnack=tcpPacket.ackNo;
    }
 else {
      System.out.println("String_Node_Str" + Integer.toString(tcpPacket.ackNo,16) + "String_Node_Str"+ Integer.toString(sendNext,16));
    }
  }
  if (receiveNext == tcpPacket.seqNo) {
  }
 else {
    System.out.println("String_Node_Str" + Integer.toString(receiveNext,16) + "String_Node_Str"+ Integer.toString(tcpPacket.seqNo,16));
  }
  receiveNext=tcpPacket.seqNo + plen;
  if (tcpPacket.isFin()) {
    if (tcpListener != null && plen > 0) {
      tcpListener.connectionClosed(this);
    }
  }
  TCPPacket tcpReply=TCPHandler.createAck(tcpPacket,0);
  tcpReply.ackNo=tcpPacket.seqNo + plen;
  tcpReply.seqNo=sendNext;
  send(tcpReply);
  if (plen > 0)   if (tcpListener != null) {
    tcpListener.tcpDataReceived(this,tcpPacket);
  }
}
Program: 5613
Project: 5613
Buggy source:
public int read() throws IOException {
  if (closed) {
    return -1;
  }
  if (firstByte == nextEmpty) {
    System.out.println("String_Node_Str");
synchronized (this) {
      try {
        wait();
        System.out.println("String_Node_Str" + available());
      }
 catch (      InterruptedException e) {
        e.printStackTrace();
      }
    }
  }
  if (!closed) {
    int data=inputBuffer[firstByte++];
    if (firstByte >= inputBuffer.length)     firstByte=0;
    return (data & 0xff);
  }
 else {
    return -1;
  }
}

Fixed version (ground truth):
public int read() throws IOException {
  if (closed) {
    return -1;
  }
  if (firstByte == nextEmpty) {
synchronized (this) {
      try {
        wait();
      }
 catch (      InterruptedException e) {
        e.printStackTrace();
      }
    }
  }
  if (!closed) {
    int data=inputBuffer[firstByte++];
    if (firstByte >= inputBuffer.length)     firstByte=0;
    return (data & 0xff);
  }
 else {
    return -1;
  }
}
Program: 5614
Project: 5614
Buggy source:
public void tcpDataReceived(TCPConnection source,TCPPacket packet){
  System.out.println("String_Node_Str");
  byte[] payload=packet.payload;
  if (payload == null || payload.length == 0)   return;
  int pos=0;
  if (inputBuffer.length - available() > payload.length) {
    while (pos < payload.length) {
      inputBuffer[nextEmpty++]=payload[pos++];
      if (nextEmpty >= inputBuffer.length) {
        nextEmpty=0;
      }
    }
    notifyReader();
  }
 else {
    System.out.println("String_Node_Str");
  }
}

Fixed version (ground truth):
public void tcpDataReceived(TCPConnection source,TCPPacket packet){
  byte[] payload=packet.payload;
  if (payload == null || payload.length == 0)   return;
  int pos=0;
  if (inputBuffer.length - available() > payload.length) {
    while (pos < payload.length) {
      inputBuffer[nextEmpty++]=payload[pos++];
      if (nextEmpty >= inputBuffer.length) {
        nextEmpty=0;
      }
    }
    notifyReader();
  }
 else {
    System.out.println("String_Node_Str");
  }
}
Program: 5615
Project: 5615
Buggy source:
public synchronized void flush() throws IOException {
  System.out.println("String_Node_Str");
  byte[] buffer=new byte[pos];
  for (int i=0; i < pos; i++) {
    buffer[i]=output[i];
  }
  pos=0;
  connection.send(buffer);
}

Fixed version (ground truth):
public synchronized void flush() throws IOException {
  byte[] buffer=new byte[pos];
  for (int i=0; i < pos; i++) {
    buffer[i]=output[i];
  }
  pos=0;
  connection.send(buffer);
}
Program: 5616
Project: 5616
Buggy source:
public void printPacket(PrintStream out){
  out.println("String_Node_Str" + sourcePort + "String_Node_Str"+ destinationPort+ "String_Node_Str"+ Utils.hex8(flags));
  out.println("String_Node_Str" + seqNo + "String_Node_Str"+ ackNo);
  if (payload != null) {
    for (int i=0; i < payload.length; i++) {
      out.print((char)payload[i]);
    }
    System.out.println();
  }
}

Fixed version (ground truth):
public void printPacket(PrintStream out){
  out.print("String_Node_Str" + sourcePort + "String_Node_Str"+ destinationPort+ "String_Node_Str"+ Utils.hex8(flags)+ "String_Node_Str"+ Integer.toString(seqNo,16)+ "String_Node_Str"+ Integer.toString(ackNo,16));
  if (payload != null) {
    System.out.print("String_Node_Str");
    int len=8;
    if (payload.length < len)     len=payload.length;
    for (int i=0; i < len; i++) {
      out.print((char)payload[i]);
    }
  }
  System.out.println("String_Node_Str");
}
Program: 5617
Project: 5617
Buggy source:
private void programPage(){
  writeStatus(0.64);
  ensureLoaded(blockWriteAddress);
  for (int i=0; i < readMemory.length; i++) {
    readMemory[i]&=buffer[i];
  }
  writeBack(blockWriteAddress,readMemory);
}

Fixed version (ground truth):
private void programPage(){
  if (writing)   System.out.println("String_Node_Str" + cpu.getPC());
  writeStatus(PROGRAM_PAGE_MILLIS);
  ensureLoaded(blockWriteAddress);
  for (int i=0; i < readMemory.length; i++) {
    readMemory[i]&=buffer[i];
  }
  writeBack(blockWriteAddress,readMemory);
}
Program: 5619
Project: 5619
Buggy source:
private void sectorErase(int address){
  writeStatus(600);
  int sectorAddress=address & 0xf0000;
  loadedAddress=-1;
  for (int i=0; i < buffer.length; i++) {
    buffer[i]=(byte)0xff;
  }
  blockWriteAddress=sectorAddress;
  for (int i=0; i < 0x100; i++) {
    if (DEBUG) {
      System.out.println("String_Node_Str" + Integer.toHexString(blockWriteAddress));
    }
    writeBack(blockWriteAddress,buffer);
    blockWriteAddress+=0x100;
  }
}

Fixed version (ground truth):
private void sectorErase(int address){
  writeStatus(SECTOR_ERASE_MILLIS);
  int sectorAddress=address & 0xf0000;
  loadedAddress=-1;
  for (int i=0; i < buffer.length; i++) {
    buffer[i]=(byte)0xff;
  }
  blockWriteAddress=sectorAddress;
  for (int i=0; i < 0x100; i++) {
    if (DEBUG) {
      System.out.println("String_Node_Str" + Integer.toHexString(blockWriteAddress));
    }
    writeBack(blockWriteAddress,buffer);
    blockWriteAddress+=0x100;
  }
}
Program: 5622
Project: 5622
Buggy source:
private void sendFIN(){
  System.out.println("String_Node_Str");
  TCPPacket packet=createPacket();
  packet.flags|=TCPPacket.FIN;
  state=FIN_WAIT_1;
  send(packet);
}

Fixed version (ground truth):
void sendFIN(){
  System.out.println("String_Node_Str");
  TCPPacket packet=createPacket();
  packet.flags|=TCPPacket.FIN;
  try {
    send(packet);
  }
 catch (  IOException e) {
    e.printStackTrace();
  }
}
Program: 5623
Project: 5623
Buggy source:
void sendAck(TCPPacket tcpPacket){
  TCPPacket tcpReply=TCPHandler.createAck(tcpPacket,0);
  tcpReply.ackNo=receiveNext;
  tcpReply.seqNo=sendNext;
  send(tcpReply);
}

Fixed version (ground truth):
void sendAck(TCPPacket tcpPacket){
  TCPPacket tcpReply=TCPHandler.createAck(tcpPacket,0);
  try {
    send(tcpReply);
  }
 catch (  IOException e) {
    e.printStackTrace();
  }
}
Program: 5624
Project: 5624
Buggy source:
private synchronized void copyToBuffer(byte[] data){
  int empty=outgoingBuffer.length - outSize();
  while (empty < data.length || state != TCPConnection.ESTABLISHED) {
    try {
      System.out.println("String_Node_Str");
      wait(1000);
    }
 catch (    InterruptedException e) {
      e.printStackTrace();
      return;
    }
    empty=outgoingBuffer.length - outSize();
  }
  for (int i=0; i < data.length; i++) {
    outgoingBuffer[bufNextEmpty++]=data[i];
    if (bufNextEmpty >= outgoingBuffer.length)     bufNextEmpty=0;
  }
}

Fixed version (ground truth):
private synchronized void copyToBuffer(byte[] data) throws IOException {
  int empty=outgoingBuffer.length - outSize();
  while (empty < data.length || state == TCPConnection.SYN_RECEIVED || state == TCPConnection.SYN_SENT) {
    if (state == TCPConnection.CLOSED)     throw new IOException("String_Node_Str");
    try {
      System.out.println("String_Node_Str" + state);
      wait(1000);
    }
 catch (    InterruptedException e) {
      e.printStackTrace();
      return;
    }
    empty=outgoingBuffer.length - outSize();
  }
  for (int i=0; i < data.length; i++) {
    outgoingBuffer[bufNextEmpty++]=data[i];
    if (bufNextEmpty >= outgoingBuffer.length)     bufNextEmpty=0;
  }
}
Program: 5625
Project: 5625
Buggy source:
public void close(){
  if (state == ESTABLISHED) {
    System.out.println("String_Node_Str" + outSize());
    closing=true;
    if (outSize() == 0) {
      sendFIN();
    }
  }
}

Fixed version (ground truth):
public void close(){
  if (state == ESTABLISHED) {
    System.out.println("String_Node_Str" + outSize());
    closing=true;
    if (outSize() == 0) {
      state=FIN_WAIT_1;
      sendFIN();
    }
  }
}
Program: 5626
Project: 5626
Buggy source:
private synchronized void addConnection(TCPConnection c){
  activeConnections[connectionNo++]=c;
}

Fixed version (ground truth):
private synchronized void addConnection(TCPConnection c){
  c.pos=(byte)connectionNo;
  activeConnections[connectionNo++]=c;
}
Program: 5628
Project: 5628
Buggy source:
public synchronized void run(){
  if (connectionNo > 0) {
    long time=System.currentTimeMillis();
    for (int i=0; i < connectionNo; i++) {
      TCPConnection connection=activeConnections[i];
switch (connection.state) {
case TCPConnection.ESTABLISHED:
        if (connection.outSize() > 0 && (connection.lastSendTime + connection.retransmissionTime < time)) {
          System.out.println("String_Node_Str");
          connection.resend();
        }
      break;
case TCPConnection.CLOSE_WAIT:
    if (connection.bufPos == connection.bufNextEmpty) {
      System.out.println("String_Node_Str");
      TCPPacket packet=connection.createPacket();
      packet.flags|=TCPPacket.FIN;
      connection.state=TCPConnection.LAST_ACK;
      connection.send(packet);
    }
 else {
    }
  break;
case TCPConnection.TIME_WAIT:
if (connection.lastSendTime < time + TCPConnection.TIME_WAIT_MILLIS) {
  System.out.println("String_Node_Str");
  connection.state=TCPConnection.CLOSED;
  connectionNo--;
  if (i > 0) {
    activeConnections[i]=activeConnections[connectionNo];
    i--;
  }
}
break;
}
}
}
}

Fixed version (ground truth):
public synchronized void run(){
  if (connectionNo > 0) {
    long time=System.currentTimeMillis();
    for (int i=0; i < connectionNo; i++) {
      TCPConnection connection=activeConnections[i];
switch (connection.state) {
case TCPConnection.ESTABLISHED:
        if (connection.outSize() > 0 && (connection.lastSendTime + connection.retransmissionTime < time)) {
          System.out.println("String_Node_Str");
          connection.resend();
        }
      if (connection.timeout != -1) {
        if (connection.lastSendTime + connection.timeout < time) {
          connection.close();
        }
      }
    break;
case TCPConnection.CLOSE_WAIT:
  if (connection.outSize() == 0) {
    System.out.println("String_Node_Str");
    connection.state=TCPConnection.LAST_ACK;
    connection.sendFIN();
  }
 else {
    connection.resend();
  }
break;
case TCPConnection.TIME_WAIT:
if (connection.lastSendTime + TCPConnection.TIME_WAIT_MILLIS < time) {
System.out.println("String_Node_Str");
connection.state=TCPConnection.CLOSED;
}
break;
case TCPConnection.CLOSED:
System.out.println("String_Node_Str" + connection.pos);
connection.closed();
connectionNo--;
if (connectionNo > 0) {
activeConnections[i]=activeConnections[connectionNo];
activeConnections[i].pos=(byte)i;
i--;
}
break;
}
}
}
}
Program: 5629
Project: 5629
Buggy source:
public void connectionClosed(TCPConnection connection){
}

Fixed version (ground truth):
public void connectionClosed(TCPConnection connection){
  closed=true;
  System.out.println("String_Node_Str");
  notifyReader();
}
Program: 5630
Project: 5630
Buggy source:
void receive(TCPPacket tcpPacket){
  int plen=tcpPacket.payload == null ? 0 : tcpPacket.payload.length;
  if (tcpPacket.isAck()) {
    if (sendNext == tcpPacket.ackNo) {
      sentUnack=tcpPacket.ackNo;
    }
 else {
      System.out.println("String_Node_Str" + Integer.toString(tcpPacket.ackNo,16) + "String_Node_Str"+ Integer.toString(sendNext,16));
    }
  }
  if (receiveNext == tcpPacket.seqNo) {
  }
 else {
    System.out.println("String_Node_Str" + Integer.toString(receiveNext,16) + "String_Node_Str"+ Integer.toString(tcpPacket.seqNo,16));
  }
  receiveNext=tcpPacket.seqNo + plen;
  if (tcpPacket.isFin()) {
    if (tcpListener != null && plen > 0) {
      tcpListener.connectionClosed(this);
    }
  }
  TCPPacket tcpReply=TCPHandler.createAck(tcpPacket,0);
  tcpReply.ackNo=tcpPacket.seqNo + plen;
  tcpReply.seqNo=sendNext;
  send(tcpReply);
  if (plen > 0)   if (tcpListener != null) {
    tcpListener.tcpDataReceived(this,tcpPacket);
  }
}

Fixed version (ground truth):
synchronized void receive(TCPPacket tcpPacket){
  int plen=tcpPacket.payload == null ? 0 : tcpPacket.payload.length;
  if (tcpPacket.isAck()) {
    if (sendNext == tcpPacket.ackNo) {
      int noAcked=tcpPacket.ackNo - sentUnack;
      sentUnack=tcpPacket.ackNo;
      bufPos+=noAcked;
      System.out.println("String_Node_Str" + noAcked + "String_Node_Str"+ bufPos+ "String_Node_Str"+ bufNextEmpty);
      notify();
    }
 else {
      System.out.println("String_Node_Str" + Integer.toString(tcpPacket.ackNo,16) + "String_Node_Str"+ Integer.toString(sendNext,16)+ "String_Node_Str"+ Integer.toString(sentUnack,16));
      if (tcpPacket.ackNo == sentUnack) {
        resend();
      }
    }
  }
  if (receiveNext == tcpPacket.seqNo) {
  }
 else {
    System.out.println("String_Node_Str" + Integer.toString(receiveNext,16) + "String_Node_Str"+ Integer.toString(tcpPacket.seqNo,16));
  }
  receiveNext=tcpPacket.seqNo + plen;
  if (tcpPacket.isFin()) {
    if (tcpListener != null && plen > 0) {
      tcpListener.connectionClosed(this);
    }
  }
  if (plen > 0) {
    TCPPacket tcpReply=TCPHandler.createAck(tcpPacket,0);
    tcpReply.ackNo=tcpPacket.seqNo + plen;
    tcpReply.seqNo=sendNext;
    send(tcpReply);
    if (tcpListener != null) {
      tcpListener.tcpDataReceived(this,tcpPacket);
    }
  }
}
Program: 5632
Project: 5632
Buggy source:
public synchronized void run(){
  if (connectionNo > 0) {
    long time=System.currentTimeMillis();
    for (int i=0; i < connectionNo; i++) {
      TCPConnection connection=activeConnections[i];
switch (connection.state) {
case TCPConnection.CLOSE_WAIT:
        if (connection.bufFirst == connection.bufLast) {
          System.out.println("String_Node_Str");
          TCPPacket packet=connection.createPacket();
          packet.flags|=TCPPacket.FIN;
          connection.state=TCPConnection.LAST_ACK;
          connection.send(packet);
        }
 else {
        }
      break;
case TCPConnection.TIME_WAIT:
    if (connection.lastSendTime < time + TCPConnection.TIME_WAIT_MILLIS) {
      System.out.println("String_Node_Str");
      connection.state=TCPConnection.CLOSED;
      connectionNo--;
      if (i > 0) {
        activeConnections[i]=activeConnections[connectionNo];
        i--;
      }
    }
  break;
}
}
}
}

Fixed version (ground truth):
public synchronized void run(){
  if (connectionNo > 0) {
    long time=System.currentTimeMillis();
    for (int i=0; i < connectionNo; i++) {
      TCPConnection connection=activeConnections[i];
switch (connection.state) {
case TCPConnection.CLOSE_WAIT:
        if (connection.bufPos == connection.bufNextEmpty) {
          System.out.println("String_Node_Str");
          TCPPacket packet=connection.createPacket();
          packet.flags|=TCPPacket.FIN;
          connection.state=TCPConnection.LAST_ACK;
          connection.send(packet);
        }
 else {
        }
      break;
case TCPConnection.TIME_WAIT:
    if (connection.lastSendTime < time + TCPConnection.TIME_WAIT_MILLIS) {
      System.out.println("String_Node_Str");
      connection.state=TCPConnection.CLOSED;
      connectionNo--;
      if (i > 0) {
        activeConnections[i]=activeConnections[connectionNo];
        i--;
      }
    }
  break;
}
}
}
}
Program: 5633
Project: 5633
Buggy source:
private synchronized void notifyReader(){
  System.out.println("String_Node_Str");
  notify();
}

Fixed version (ground truth):
private synchronized void notifyReader(){
  notify();
}
Program: 5634
Project: 5634
Buggy source:
public void parsePacketData(IPv6Packet packet){
  sourcePort=packet.get16(0);
  destinationPort=packet.get16(2);
  seqNo=packet.get32(4);
  ackNo=packet.get32(8);
  offset=(packet.getData(12) & 0xff) >> 4;
  flags=packet.getData(13);
  window=packet.get16(14);
  checksum=packet.get16(16);
  urgentPointer=packet.get16(18);
  packet.setData(16,(byte)0);
  packet.setData(17,(byte)0);
  byte[] data=packet.getPayload();
  int sum=packet.upperLayerHeaderChecksum();
  sum=IPv6Packet.checkSum(sum,data,data.length);
  sum=(~sum) & 0xffff;
  if (sum == checksum) {
  }
 else {
    System.out.println("String_Node_Str" + Utils.hex16(checksum) + "String_Node_Str"+ Utils.hex16(sum));
  }
  if (data.length - (offset * 4) > 0) {
    int len=data.length - (offset * 4);
    System.out.println("String_Node_Str" + offset + "String_Node_Str"+ len);
    payload=new byte[len];
    System.arraycopy(data,(offset * 4),payload,0,len);
  }
}

Fixed version (ground truth):
public void parsePacketData(IPv6Packet packet){
  sourcePort=packet.get16(0);
  destinationPort=packet.get16(2);
  seqNo=packet.get32(4);
  ackNo=packet.get32(8);
  offset=(packet.getData(12) & 0xff) >> 4;
  flags=packet.getData(13);
  window=packet.get16(14);
  checksum=packet.get16(16);
  urgentPointer=packet.get16(18);
  packet.setData(16,(byte)0);
  packet.setData(17,(byte)0);
  byte[] data=packet.getPayload();
  int sum=packet.upperLayerHeaderChecksum();
  sum=IPv6Packet.checkSum(sum,data,data.length);
  sum=(~sum) & 0xffff;
  if (sum == checksum) {
  }
 else {
    System.out.println("String_Node_Str" + Utils.hex16(checksum) + "String_Node_Str"+ Utils.hex16(sum));
  }
  if (data.length - (offset * 4) > 0) {
    int len=data.length - (offset * 4);
    payload=new byte[len];
    System.arraycopy(data,(offset * 4),payload,0,len);
  }
}
Program: 5635
Project: 5635
Buggy source:
public void parsePacketData(IPv6Packet packet){
  dispatch=packet.getDispatch();
  payloadData=packet.getPayload();
}

Fixed version (ground truth):
public void parsePacketData(IPv6Packet packet){
  dispatch=packet.getDispatch();
  payloadData=packet.getPayload();
  int len=0;
  if (payloadData != null)   len=payloadData.length;
  System.out.println("String_Node_Str" + len + "String_Node_Str");
}
Program: 5638
Project: 5638
Buggy source:
public void receiveNDMessage(IPv6Packet packet){
  ICMP6Packet payload=(ICMP6Packet)packet.getIPPayload();
  Neighbor nei=null;
switch (payload.type) {
case ICMP6Packet.ROUTER_SOLICITATION:
    nei=neigborTable.addNeighbor(packet.sourceAddress,packet.getLinkSource());
  if (nei != null) {
    nei.setState(Neighbor.REACHABLE);
  }
break;
case ICMP6Packet.ROUTER_ADVERTISEMENT:
nei=neigborTable.addNeighbor(packet.sourceAddress,packet.getLinkSource());
neigborTable.setDefrouter(nei);
nei.setState(Neighbor.REACHABLE);
break;
}
}

Fixed version (ground truth):
public void receiveNDMessage(IPv6Packet packet){
  ICMP6Packet payload=(ICMP6Packet)packet.getIPPayload();
  Neighbor nei=null;
switch (payload.type) {
case ICMP6Packet.ROUTER_SOLICITATION:
    nei=neigborTable.addNeighbor(packet.sourceAddress,packet.getLinkSource());
  if (nei != null) {
    nei.setState(Neighbor.REACHABLE);
  }
if (ipStack.isRouter()) {
  ICMP6Packet p=new ICMP6Packet();
  p.targetAddress=payload.targetAddress;
  p.type=ICMP6Packet.ROUTER_ADVERTISEMENT;
  p.flags=ICMP6Packet.FLAG_SOLICITED | ICMP6Packet.FLAG_OVERRIDE;
  p.updateRA(ipStack);
  IPv6Packet ipp=new IPv6Packet();
  ipp.setIPPayload(p);
  ipp.destAddress=IPStack.ALL_NODES;
  ipp.sourceAddress=ipStack.myLocalIPAddress;
  System.out.print("String_Node_Str");
  IPv6Packet.printAddress(System.out,ipp.destAddress);
  packet.printPacket(System.out);
  ipStack.sendPacket(ipp,packet.netInterface);
}
break;
case ICMP6Packet.ROUTER_ADVERTISEMENT:
nei=neigborTable.addNeighbor(packet.sourceAddress,packet.getLinkSource());
neigborTable.setDefrouter(nei);
nei.setState(Neighbor.REACHABLE);
break;
}
}
Program: 5639
Project: 5639
Buggy source:
public byte[] generatePacketData(IPv6Packet packet){
  return null;
}

Fixed version (ground truth):
public byte[] generatePacketData(IPv6Packet packet){
  int size=payload != null ? payload.length : 0;
  size+=8;
  byte[] data=new byte[size];
  int pos=0;
  data[pos++]=(byte)(sourcePort >> 8);
  data[pos++]=(byte)(sourcePort & 0xff);
  data[pos++]=(byte)(destinationPort >> 8);
  data[pos++]=(byte)(destinationPort & 0xff);
  data[pos++]=(byte)(size >> 8);
  data[pos++]=(byte)(size & 0xff);
  data[pos++]=0;
  data[pos++]=0;
  if (payload != null) {
    System.arraycopy(payload,0,data,pos,payload.length);
  }
  packet.payloadLen=size;
  int sum=packet.upperLayerHeaderChecksum();
  sum=IPv6Packet.checkSum(sum,data,size);
  sum=(~sum) & 0xffff;
  data[6]=(byte)(sum >> 8);
  data[7]=(byte)(sum & 0xff);
  return data;
}
Program: 5641
Project: 5641
Buggy source:
public void parsePacketData(IPv6Packet packet){
  if (packet.nextHeader == 58) {
    type=packet.getData(0) & 0xff;
    code=packet.getData(1) & 0xff;
    checksum=((packet.getData(2) & 0xff) << 8) | packet.getData(3) & 0xff;
    packet.setData(2,(byte)0);
    packet.setData(3,(byte)0);
switch (type) {
case ECHO_REQUEST:
case ECHO_REPLY:
      id=packet.get16(4);
    seqNo=packet.get16(6);
  break;
case NEIGHBOR_SOLICITATION:
case NEIGHBOR_ADVERTISEMENT:
if (type == NEIGHBOR_ADVERTISEMENT) {
  flags=packet.getData(4) & 0xff;
}
packet.copy(8,targetAddress,0,16);
break;
}
byte[] data=packet.getPayload();
System.out.println("String_Node_Str" + data.length);
int sum=packet.upperLayerHeaderChecksum();
sum=IPv6Packet.checkSum(sum,data,data.length);
sum=(~sum) & 0xffff;
if (sum == checksum) {
System.out.println("String_Node_Str");
}
 else {
System.out.printf("String_Node_Str",checksum,sum);
}
}
}

Fixed version (ground truth):
public void parsePacketData(IPv6Packet packet){
  if (packet.nextHeader == 58) {
    type=packet.getData(0) & 0xff;
    code=packet.getData(1) & 0xff;
    checksum=((packet.getData(2) & 0xff) << 8) | packet.getData(3) & 0xff;
    packet.setData(2,(byte)0);
    packet.setData(3,(byte)0);
switch (type) {
case ECHO_REQUEST:
case ECHO_REPLY:
      id=packet.get16(4);
    seqNo=packet.get16(6);
  break;
case NEIGHBOR_SOLICITATION:
case NEIGHBOR_ADVERTISEMENT:
if (type == NEIGHBOR_ADVERTISEMENT) {
  flags=packet.getData(4) & 0xff;
}
targetAddress=new byte[16];
packet.copy(8,targetAddress,0,16);
break;
}
byte[] data=packet.getPayload();
System.out.println("String_Node_Str" + data.length);
int sum=packet.upperLayerHeaderChecksum();
sum=IPv6Packet.checkSum(sum,data,data.length);
sum=(~sum) & 0xffff;
if (sum == checksum) {
System.out.println("String_Node_Str");
}
 else {
System.out.printf("String_Node_Str",checksum,sum);
}
}
}
Program: 5642
Project: 5642
Buggy source:
public void handlePacket(IPv6Packet packet){
  ICMP6Packet icmpPacket=new ICMP6Packet();
  icmpPacket.parsePacketData(packet);
  icmpPacket.printPacket(System.out);
  ICMP6Packet p;
  IPv6Packet ipp;
switch (icmpPacket.type) {
case ICMP6Packet.NEIGHBOR_SOLICITATION:
    p=new ICMP6Packet();
  p.targetAddress=icmpPacket.targetAddress;
p.type=ICMP6Packet.NEIGHBOR_ADVERTISEMENT;
p.flags=ICMP6Packet.FLAG_SOLICITED | ICMP6Packet.FLAG_OVERRIDE;
ipp=new IPv6Packet();
ipp.setIPPayload(p);
ipp.destAddress=packet.sourceAddress;
ipStack.sendPacket(ipp);
break;
case ICMP6Packet.ROUTER_SOLICITATION:
p=new ICMP6Packet();
p.targetAddress=icmpPacket.targetAddress;
p.type=ICMP6Packet.ROUTER_ADVERTISEMENT;
p.flags=ICMP6Packet.FLAG_SOLICITED | ICMP6Packet.FLAG_OVERRIDE;
ipp=new IPv6Packet();
ipp.setIPPayload(p);
ipp.destAddress=packet.sourceAddress;
ipStack.sendPacket(ipp);
break;
}
}

Fixed version (ground truth):
public void handlePacket(IPv6Packet packet){
  ICMP6Packet icmpPacket=new ICMP6Packet();
  icmpPacket.parsePacketData(packet);
  icmpPacket.printPacket(System.out);
  ICMP6Packet p;
  IPv6Packet ipp;
switch (icmpPacket.type) {
case ICMP6Packet.NEIGHBOR_SOLICITATION:
    p=new ICMP6Packet();
  p.targetAddress=icmpPacket.targetAddress;
p.type=ICMP6Packet.NEIGHBOR_ADVERTISEMENT;
p.flags=ICMP6Packet.FLAG_SOLICITED | ICMP6Packet.FLAG_OVERRIDE;
ipp=new IPv6Packet();
ipp.setIPPayload(p);
ipp.destAddress=packet.sourceAddress;
ipStack.sendPacket(ipp);
break;
case ICMP6Packet.ROUTER_SOLICITATION:
p=new ICMP6Packet();
p.targetAddress=icmpPacket.targetAddress;
p.type=ICMP6Packet.ROUTER_ADVERTISEMENT;
p.flags=ICMP6Packet.FLAG_SOLICITED | ICMP6Packet.FLAG_OVERRIDE;
p.updateRA(ipStack);
ipp=new IPv6Packet();
ipp.setIPPayload(p);
ipp.destAddress=packet.sourceAddress;
System.out.print("String_Node_Str");
IPv6Packet.printAddress(System.out,ipp.destAddress);
ipStack.sendPacket(ipp);
break;
}
}
Program: 5643
Project: 5643
Buggy source:
public int read(int address,boolean word,long cycles){
  if (address == TAIV || address == TBIV) {
    int val=lastTIV;
    resetTIV(cycles);
    return val;
  }
  int val=0;
  int index=address - offset;
switch (index) {
case TR:
    val=updateCounter(cycles);
  break;
case TCTL:
val=tctl;
if (interruptPending) {
val|=1;
}
 else {
val&=0xfffe;
}
if (DEBUG) {
System.out.println(getName() + "String_Node_Str" + "String_Node_Str"+ inputDivider+ "String_Node_Str"+ getSourceName(clockSource)+ "String_Node_Str"+ interruptEnable+ "String_Node_Str"+ interruptPending+ "String_Node_Str"+ mode);
}
break;
case TCCTL0:
case TCCTL1:
case TCCTL2:
case TCCTL3:
case TCCTL4:
case TCCTL5:
case TCCTL6:
int i=(index - TCCTL0) / 2;
val=tcctl[i];
break;
case TCCR0:
case TCCR1:
case TCCR2:
case TCCR3:
case TCCR4:
case TCCR5:
case TCCR6:
i=(index - TCCR0) / 2;
val=tccr[i];
break;
default :
System.out.println("String_Node_Str");
}
if (DEBUG && false) {
System.out.println(getName() + "String_Node_Str" + getName(address)+ "String_Node_Str"+ Utils.hex16(address)+ "String_Node_Str"+ Utils.hex16(val)+ "String_Node_Str"+ val+ "String_Node_Str");
}
return val & 0xffff;
}

Fixed version (ground truth):
public int read(int address,boolean word,long cycles){
  if (address == TAIV || address == TBIV) {
    int val=lastTIV;
    resetTIV(cycles);
    return val;
  }
  int val=0;
  int index=address - offset;
switch (index) {
case TR:
    val=updateCounter(cycles);
  break;
case TCTL:
val=tctl;
if (interruptPending) {
val|=1;
}
 else {
val&=0xfffe;
}
if (DEBUG) {
System.out.println(getName() + "String_Node_Str" + "String_Node_Str"+ inputDivider+ "String_Node_Str"+ getSourceName(clockSource)+ "String_Node_Str"+ interruptEnable+ "String_Node_Str"+ interruptPending+ "String_Node_Str"+ mode);
}
break;
case TCCTL0:
case TCCTL1:
case TCCTL2:
case TCCTL3:
case TCCTL4:
case TCCTL5:
case TCCTL6:
int i=(index - TCCTL0) / 2;
updateTCCTL(i,cycles);
val=tcctl[i];
break;
case TCCR0:
case TCCR1:
case TCCR2:
case TCCR3:
case TCCR4:
case TCCR5:
case TCCR6:
i=(index - TCCR0) / 2;
val=tccr[i];
break;
default :
System.out.println("String_Node_Str");
}
if (DEBUG && false) {
System.out.println(getName() + "String_Node_Str" + getName(address)+ "String_Node_Str"+ Utils.hex16(address)+ "String_Node_Str"+ Utils.hex16(val)+ "String_Node_Str"+ val+ "String_Node_Str");
}
return val & 0xffff;
}
Program: 5645
Project: 5645
Buggy source:
private int updateCounter(long cycles){
  if (mode == STOP)   return counter;
  double divider=1;
  if (clockSource == SRC_ACLK) {
    divider=1.0 * core.smclkFrq / core.aclkFrq;
  }
  divider=divider * inputDivider;
  long cycctr=cycles - counterStart;
  double tick=cycctr / divider;
  counterPassed=(int)(divider * (tick - (long)(tick)));
  long bigCounter=(long)(tick + counterAcc);
switch (mode) {
case CONTIN:
    counter=(int)(bigCounter & 0xffff);
  break;
case UP:
counter=(int)(bigCounter % tccr[0]);
break;
case UPDWN:
counter=(int)(bigCounter % (tccr[0] * 2));
if (counter > tccr[0]) {
counter=2 * tccr[0] - counter;
}
}
if (DEBUG) {
System.out.println(getName() + "String_Node_Str" + cycctr+ "String_Node_Str"+ divider+ "String_Node_Str"+ mode+ "String_Node_Str"+ counter);
}
return counter;
}

Fixed version (ground truth):
private int updateCounter(long cycles){
  if (mode == STOP)   return counter;
  double divider=1;
  if (clockSource == SRC_ACLK) {
    divider=1.0 * core.smclkFrq / core.aclkFrq;
  }
  divider=divider * inputDivider;
  long cycctr=cycles - counterStart;
  double tick=cycctr / divider;
  counterPassed=(int)(divider * (tick - (long)(tick)));
  long bigCounter=(long)(tick + counterAcc);
switch (mode) {
case CONTIN:
    counter=(int)(bigCounter & 0xffff);
  break;
case UP:
if (tccr[0] == 0) {
  counter=0;
}
 else {
  counter=(int)(bigCounter % tccr[0]);
}
break;
case UPDWN:
if (tccr[0] == 0) {
counter=0;
}
 else {
counter=(int)(bigCounter % (tccr[0] * 2));
if (counter > tccr[0]) {
counter=2 * tccr[0] - counter;
}
}
}
if (DEBUG) {
System.out.println(getName() + "String_Node_Str" + cycctr+ "String_Node_Str"+ divider+ "String_Node_Str"+ mode+ "String_Node_Str"+ counter);
}
return counter;
}
Program: 5648
Project: 5648
Buggy source:
public HC01Packeter(){
  contexts[0]=new AddrContext();
  contexts[1]=new AddrContext();
  contexts[2]=new AddrContext();
  contexts[3]=new AddrContext();
  contexts[0].used=1;
  contexts[0].number=0;
  contexts[0].prefix[0]=(byte)0xfe;
  contexts[0].prefix[1]=(byte)0x80;
  contexts[1].used=1;
  contexts[1].number=1;
  contexts[1].prefix[0]=(byte)0xaa;
  contexts[1].prefix[1]=(byte)0xaa;
}

Fixed version (ground truth):
public HC01Packeter(){
  contexts[0]=new AddrContext();
  contexts[1]=new AddrContext();
  contexts[0].number=0;
  contexts[0].prefix[0]=(byte)0xfe;
  contexts[0].prefix[1]=(byte)0x80;
  contexts[1].number=1;
  contexts[1].prefix[0]=(byte)0xaa;
  contexts[1].prefix[1]=(byte)0xaa;
}
Program: 5651
Project: 5651
Buggy source:
public static boolean isELF(File file){
  InputStream input=null;
  try {
    input=new FileInputStream(file);
    for (int i=0; i < MAGIC.length; i++) {
      if (MAGIC[i] != input.read()) {
        return false;
      }
    }
  }
 catch (  IOException ioe) {
  }
 finally {
    if (input != null) {
      try {
        input.close();
      }
 catch (      Exception e) {
      }
    }
  }
  return true;
}

Fixed version (ground truth):
public static boolean isELF(File file){
  InputStream input=null;
  try {
    input=new FileInputStream(file);
    for (int i=0; i < MAGIC.length; i++) {
      if (MAGIC[i] != input.read()) {
        return false;
      }
    }
  }
 catch (  IOException ioe) {
    return false;
  }
 finally {
    if (input != null) {
      try {
        input.close();
      }
 catch (      Exception e) {
      }
    }
  }
  return true;
}
Program: 5652
Project: 5652
Buggy source:
public void interruptServiced(int vector){
}

Fixed version (ground truth):
public void interruptServiced(int vector){
  irqTriggered[vector]=false;
  int pos=irqTriggeredPos[vector];
  int bit=pos & 7;
  if (pos > 8) {
    ifg1&=~(1 << bit);
  }
 else {
    ifg2&=~(1 << bit);
  }
  cpu.flagInterrupt(vector,this,false);
  if (sfrModule[pos] != null) {
    sfrModule[pos].interruptServiced(vector);
  }
}
Program: 5653
Project: 5653
Buggy source:
private void updateIRQ(int pos,int change){
  int ifg=pos == 0 ? ifg1 : ifg2;
  int ie=pos == 0 ? ie1 : ie2;
  pos=pos * 8;
  for (int i=0; i < 8; i++) {
    if ((change & 1) == 1) {
      if (sfrModule[pos] != null) {
        if (DEBUG)         System.out.println("String_Node_Str" + sfrModule[pos].getName() + "String_Node_Str"+ (ie & ifg & 1));
        cpu.flagInterrupt(irqVector[pos],sfrModule[pos],(ie & ifg & 1) > 0);
      }
    }
    pos++;
    change=change >> 1;
    ifg=ifg >> 1;
    ie=ie >> 1;
  }
}

Fixed version (ground truth):
private void updateIRQ(int pos,int change){
  int ifg=pos == 0 ? ifg1 : ifg2;
  int ie=pos == 0 ? ie1 : ie2;
  pos=pos * 8;
  for (int i=0; i < 8; i++) {
    if ((change & 1) == 1) {
      if (sfrModule[pos] != null && !irqTriggered[irqVector[pos]]) {
        if (DEBUG)         System.out.println("String_Node_Str" + sfrModule[pos].getName() + "String_Node_Str"+ pos+ "String_Node_Str"+ (ie & ifg & 1)+ "String_Node_Str"+ change);
        if ((ie & ifg & 1) > 0) {
          int vector=irqVector[pos];
          irqTriggered[vector]=true;
          irqTriggeredPos[vector]=pos;
          cpu.flagInterrupt(irqVector[pos],this,true);
        }
      }
    }
    pos++;
    change=change >> 1;
    ifg=ifg >> 1;
    ie=ie >> 1;
  }
}
Program: 5654
Project: 5654
Buggy source:
public void reset(int type){
  ie1=0;
  ie2=0;
  ifg1=0;
  ifg2=0;
  me1=0;
  me2=0;
}

Fixed version (ground truth):
public void reset(int type){
  ie1=0;
  ie2=0;
  ifg1=0;
  ifg2=0;
  me1=0;
  me2=0;
  for (int i=0; i < irqTriggered.length; i++) {
    irqTriggered[i]=false;
  }
}
Program: 5655
Project: 5655
Buggy source:
public void interruptServiced(int vector){
  cpu.flagInterrupt(vector,this,false);
}

Fixed version (ground truth):
public void interruptServiced(int vector){
}
Program: 5656
Project: 5656
Buggy source:
public int read(int address,boolean word,long cycles){
  address=address - offset;
switch (address) {
case UCTL:
    if (DEBUG)     System.out.println(getName() + "String_Node_Str");
  return uctl;
case UTCTL:
if (DEBUG) System.out.println(getName() + "String_Node_Str" + utctl);
return utctl;
case URCTL:
return urctl;
case UMCTL:
return umctl;
case UBR0:
return ubr0;
case UBR1:
return ubr1;
case UTXBUF:
return utxbuf;
case URXBUF:
int tmp=urxbuf;
if (MSP430Constants.DEBUGGING_LEVEL > 0) {
System.out.println(getName() + "String_Node_Str");
}
clrBitIFG(urxifg);
if (listener != null) {
listener.stateChanged(USARTListener.RXFLAG_CLEARED);
}
return tmp;
}
return 0;
}

Fixed version (ground truth):
public int read(int address,boolean word,long cycles){
  address=address - offset;
switch (address) {
case UCTL:
    if (DEBUG)     System.out.println(getName() + "String_Node_Str");
  return uctl;
case UTCTL:
if (DEBUG) System.out.println(getName() + "String_Node_Str" + utctl);
return utctl;
case URCTL:
return urctl;
case UMCTL:
return umctl;
case UBR0:
return ubr0;
case UBR1:
return ubr1;
case UTXBUF:
return utxbuf;
case URXBUF:
int tmp=urxbuf;
if (MSP430Constants.DEBUGGING_LEVEL > 0) {
System.out.println(getName() + "String_Node_Str" + cpu.getPC());
}
clrBitIFG(urxifg);
if (listener != null) {
listener.stateChanged(USARTListener.RXFLAG_CLEARED);
}
return tmp;
}
return 0;
}
Program: 5657
Project: 5657
Buggy source:
/** 
 * Creates a new <code>USART</code> instance.
 */
public USART(MSP430Core cpu,int[] memory,int offset){
  super(memory,offset);
  this.cpu=cpu;
  sfr=cpu.getSFR();
  if (offset == 0x78) {
    uartID=1;
  }
  if (uartID == 0) {
    sfr.registerSFDModule(0,USART0_RX_BIT,this,USART0_RX_VEC);
    sfr.registerSFDModule(0,USART0_TX_BIT,this,USART0_TX_VEC);
    utxifg=UTXIFG0;
    urxifg=URXIFG0;
    txbit=USART0_TX_BIT;
  }
 else {
    sfr.registerSFDModule(1,USART1_RX_BIT,this,USART1_RX_VEC);
    sfr.registerSFDModule(1,USART1_TX_BIT,this,USART1_TX_VEC);
    utxifg=UTXIFG1;
    urxifg=URXIFG1;
    txbit=USART1_TX_BIT;
  }
  reset(0);
}

Fixed version (ground truth):
/** 
 * Creates a new <code>USART</code> instance.
 */
public USART(MSP430Core cpu,int[] memory,int offset){
  super(memory,offset);
  this.cpu=cpu;
  sfr=cpu.getSFR();
  if (offset == 0x78) {
    uartID=1;
  }
  if (uartID == 0) {
    sfr.registerSFDModule(0,USART0_RX_BIT,this,USART0_RX_VEC);
    sfr.registerSFDModule(0,USART0_TX_BIT,this,USART0_TX_VEC);
    utxifg=UTXIFG0;
    urxifg=URXIFG0;
    txbit=USART0_TX_BIT;
    rxVector=USART0_RX_VEC;
  }
 else {
    sfr.registerSFDModule(1,USART1_RX_BIT,this,USART1_RX_VEC);
    sfr.registerSFDModule(1,USART1_TX_BIT,this,USART1_TX_VEC);
    utxifg=UTXIFG1;
    urxifg=URXIFG1;
    txbit=USART1_TX_BIT;
    rxVector=USART1_RX_VEC;
  }
  reset(0);
}
Program: 5658
Project: 5658
Buggy source:
public void reset(int type){
  nextTXReady=cpu.cycles + 1000;
  nextTXByte=-1;
  clrBitIFG(utxifg | urxifg);
  utctl|=UTCTL_TXEMPTY;
  cpu.scheduleCycleEvent(txTrigger,nextTXReady);
  txEnabled=false;
  rxEnabled=false;
}

Fixed version (ground truth):
public void reset(int type){
  nextTXReady=cpu.cycles + 100;
  nextTXByte=-1;
  clrBitIFG(utxifg | urxifg);
  utctl|=UTCTL_TXEMPTY;
  cpu.scheduleCycleEvent(txTrigger,nextTXReady);
  txEnabled=false;
  rxEnabled=false;
}
Program: 5661
Project: 5661
Buggy source:
public void setPayloadPacket(Packet packet){
  payloadPacket=packet;
}

Fixed version (ground truth):
public void setPayloadPacket(Packet packet){
  payloadPacket=packet;
  if (packet.getContainerPacket() != this) {
    packet.setContainerPacket(this);
  }
}
Program: 5662
Project: 5662
Buggy source:
public void setContainerPacket(Packet packet){
  containerPacket=packet;
}

Fixed version (ground truth):
public void setContainerPacket(Packet packet){
  containerPacket=packet;
  if (packet.getPayloadPacket() != this) {
    packet.setPayloadPacket(this);
  }
}
Program: 5663
Project: 5663
Buggy source:
public IEEE802154Packet(Packet container){
  byte[] payload=container.getPayload();
  setPacketData(container,payload,payload.length);
}

Fixed version (ground truth):
public IEEE802154Packet(){
}
Program: 5664
Project: 5664
Buggy source:
public boolean isDestinationMACBased(){
  return false;
}

Fixed version (ground truth):
public boolean isDestinationMACBased(){
  byte[] macAddress=containerPacket.getDestinationAddress();
  return isMACBased(destAddress,macAddress);
}
Program: 5665
Project: 5665
Buggy source:
public boolean isSourceMACBased(){
  return false;
}

Fixed version (ground truth):
public boolean isSourceMACBased(){
  byte[] macAddress=containerPacket.getSourceAddress();
  return isMACBased(sourceAddress,macAddress);
}
Program: 5666
Project: 5666
Buggy source:
public static int checkSum(int sum,byte[] data,int size){
  for (int i=0; i < size; i+=2) {
    int dsum=((data[i] & 0xff) << 8) | (data[i + 1] & 0xff);
    sum=(sum + dsum) & 0xffff;
    if (sum < dsum)     sum++;
  }
  if ((size & 1) > 0) {
    int dsum=((data[size - 1] & 0xff) << 8);
    sum=(sum + dsum) & 0xffff;
    if (sum < dsum)     sum++;
  }
  return sum;
}

Fixed version (ground truth):
public static int checkSum(int sum,byte[] data,int size){
  for (int i=0; i < size - 1; i+=2) {
    int dsum=((data[i] & 0xff) << 8) | (data[i + 1] & 0xff);
    sum=(sum + dsum) & 0xffff;
    if (sum < dsum)     sum++;
  }
  if ((size & 1) > 0) {
    int dsum=((data[size - 1] & 0xff) << 8);
    sum=(sum + dsum) & 0xffff;
    if (sum < dsum)     sum++;
  }
  return sum;
}
Program: 5667
Project: 5667
Buggy source:
public void sendPacket(Packet payload){
}

Fixed version (ground truth):
public void sendPacket(Packet payload){
  if (payload instanceof IPv6Packet) {
    IEEE802154Packet p=new IEEE802154Packet();
  }
}
Program: 5668
Project: 5668
Buggy source:
public void notifyPacketHandlers(byte[] payload,int len){
  for (int i=0; i < packetHandlers.size(); i++) {
    try {
      packetHandlers.get(i).setPacketData(payload,len);
    }
 catch (    Exception e) {
    }
  }
}

Fixed version (ground truth):
public void notifyPacketHandlers(byte[] payload,int len){
  for (int i=0; i < packetHandlers.size(); i++) {
    try {
      packetHandlers.get(i).setPacketData(this,payload,len);
    }
 catch (    Exception e) {
    }
  }
}
Program: 5669
Project: 5669
Buggy source:
public void setPacketData(byte[] data,int plen){
  if (data.length > PREAMBLE.length) {
    int pos=0;
    for (int i=0; i < PREAMBLE.length; i++) {
      if (data[i] != PREAMBLE[i]) {
        throw new IllegalStateException("String_Node_Str");
      }
      pos++;
    }
    len=data[pos] & 0xff;
    if (len + 5 <= plen) {
      payload=new byte[len & 0xff];
      System.arraycopy(data,pos + 1,payload,0,len);
      System.out.println("String_Node_Str");
      valid=true;
      notifyPacketHandlers(payload,payload.length);
      return;
    }
 else {
      throw new IllegalStateException("String_Node_Str");
    }
  }
}

Fixed version (ground truth):
public void setPacketData(Packet container,byte[] data,int plen){
  if (data.length > PREAMBLE.length) {
    int pos=0;
    for (int i=0; i < PREAMBLE.length; i++) {
      if (data[i] != PREAMBLE[i]) {
        throw new IllegalStateException("String_Node_Str");
      }
      pos++;
    }
    len=data[pos] & 0xff;
    if (len + 5 <= plen) {
      payload=new byte[len & 0xff];
      System.arraycopy(data,pos + 1,payload,0,len);
      System.out.println("String_Node_Str");
      valid=true;
      notifyPacketHandlers(payload,payload.length);
      return;
    }
 else {
      throw new IllegalStateException("String_Node_Str");
    }
  }
}
Program: 5670
Project: 5670
Buggy source:
public void printPacket(PrintStream out){
  if (valid) {
    out.println("String_Node_Str" + len + "String_Node_Str");
  }
}

Fixed version (ground truth):
public void printPacket(PrintStream out){
  if (valid) {
    out.print("String_Node_Str" + len + "String_Node_Str");
    for (int i=0; i < len; i++) {
      out.printf("String_Node_Str",payload[i] & 0xff);
      if ((i & 3) == 3) {
        out.print("String_Node_Str");
      }
    }
    out.println();
  }
}
Program: 5671
Project: 5671
Buggy source:
public void receivedByte(byte data){
  packetBuffer[pos++]=data;
switch (mode) {
case SFD_SEARCH:
    if (sfdSearch < 4 && data == 0)     sfdSearch++;
  if (sfdSearch == 4 && data == 0x7a) {
    mode=LEN;
    sfdSearch=0;
  }
break;
case LEN:
mode=PACKET;
packetLen=data & 0xff;
System.out.println("String_Node_Str" + packetLen);
break;
case PACKET:
if (pos == packetLen + PREAMBLE.length + 1) {
setPacketData(packetBuffer,pos);
mode=SFD_SEARCH;
}
break;
}
}

Fixed version (ground truth):
public void receivedByte(byte data){
  packetBuffer[pos++]=data;
switch (mode) {
case SFD_SEARCH:
    if (sfdSearch < 4 && data == 0)     sfdSearch++;
  if (sfdSearch == 4 && data == 0x7a) {
    mode=LEN;
    sfdSearch=0;
  }
break;
case LEN:
mode=PACKET;
packetLen=data & 0xff;
System.out.println("String_Node_Str" + packetLen);
break;
case PACKET:
if (pos == packetLen + PREAMBLE.length + 1) {
setPacketData(this,packetBuffer,pos);
mode=SFD_SEARCH;
}
break;
}
}
Program: 5672
Project: 5672
Buggy source:
public static void main(String[] args){
  CC2420Packet p=new CC2420Packet();
  p.addInnerPacketHandler(new IEEE802154Packet());
  int[] data=new int[]{0,0,0,0,0x7a,48,0x41,0xCC,0x74,0xCD,0xAB,0x55,0x44,0x33,0xFE,0xFF,0x22,0x11,0x02,0x16,0x15,0x14,0xFE,0xFF,0x13,0x12,0x02,0x03,0xC0,0x9D,0x06,0x80,0x00,0x01,0xAD,0x39,0x00,0x50,0xAE,0xC4,0x9D,0xC6,0x00,0x00,0x00,0x01,0x50,0x10,0x13,0x10,0xE7,0xBF,0x00,0x00};
  for (int i=0; i < data.length; i++) {
    p.receivedByte((byte)(data[i] & 0xff));
  }
  p.printPacketStack(System.out);
}

Fixed version (ground truth):
public static void main(String[] args){
  CC2420Packet p=new CC2420Packet();
  IEEE802154Packet p2=new IEEE802154Packet();
  p.addInnerPacketHandler(p2);
  p2.addInnerPacketHandler(new HC01Packet());
  int[] data=new int[]{0,0,0,0,0x7a,48,0x41,0xCC,0x74,0xCD,0xAB,0x55,0x44,0x33,0xFE,0xFF,0x22,0x11,0x02,0x16,0x15,0x14,0xFE,0xFF,0x13,0x12,0x02,0x03,0xC0,0x9D,0x06,0x80,0x00,0x01,0xAD,0x39,0x00,0x50,0xAE,0xC4,0x9D,0xC6,0x00,0x00,0x00,0x01,0x50,0x10,0x13,0x10,0xE7,0xBF,0x00,0x00};
  for (int i=0; i < data.length; i++) {
    p.receivedByte((byte)(data[i] & 0xff));
  }
  p.printPacketStack(System.out);
}
Program: 5674
Project: 5674
Buggy source:
public void profileRETI(long cycles){
  if (servicedInterrupt > -1) {
    interruptTime[servicedInterrupt]+=cycles - lastInterruptTime[servicedInterrupt];
    interruptCount[servicedInterrupt]++;
  }
  newIRQ=false;
  if (logger != null && !hideIRQ) {
    logger.println("String_Node_Str" + servicedInterrupt + "String_Node_Str"+ (cycles - lastInterruptTime[servicedInterrupt]));
    interruptLevel=0;
  }
  servicedInterrupt=-1;
}

Fixed version (ground truth):
public void profileRETI(long cycles){
  if (servicedInterrupt > -1) {
    interruptTime[servicedInterrupt]+=cycles - lastInterruptTime[servicedInterrupt];
    interruptCount[servicedInterrupt]++;
  }
  newIRQ=false;
  if (logger != null && !hideIRQ) {
    logger.println("String_Node_Str" + servicedInterrupt + "String_Node_Str"+ (cycles - lastInterruptTime[servicedInterrupt]));
  }
  interruptLevel=0;
  servicedInterrupt=-1;
}
Program: 5675
Project: 5675
Buggy source:
public int read(int address,boolean word,long cycles){
switch (address) {
case ADC12CTL0:
    return adc12ctl0;
case ADC12CTL1:
  return adc12ctl1;
case ADC12IE:
return adc12ie;
case ADC12IFG:
return adc12ifg;
default :
if (address >= ADC12MCTL0 && address <= ADC12MCTL15) {
return adc12mctl[address - ADC12MCTL0];
}
 else if (address >= ADC12MEM0) {
int reg=address - ADC12MEM0;
adc12ifg&=~(1 << reg);
if (adc12iv == reg + 6) {
core.flagInterrupt(adc12Vector,this,false);
adc12iv=0;
}
return adc12mem[reg];
}
}
return 0;
}

Fixed version (ground truth):
public int read(int address,boolean word,long cycles){
switch (address) {
case ADC12CTL0:
    return adc12ctl0;
case ADC12CTL1:
  return adc12ctl1;
case ADC12IE:
return adc12ie;
case ADC12IFG:
return adc12ifg;
default :
if (address >= ADC12MCTL0 && address <= ADC12MCTL15) {
return adc12mctl[address - ADC12MCTL0];
}
 else if (address >= ADC12MEM0) {
int reg=(address - ADC12MEM0) / 2;
adc12ifg&=~(1 << reg);
if (adc12iv == reg * 2 + 6) {
core.flagInterrupt(adc12Vector,this,false);
adc12iv=0;
}
return adc12mem[reg];
}
}
return 0;
}
Program: 5676
Project: 5676
Buggy source:
public TimeEvent popFirst(){
  TimeEvent tmp=first;
  if (tmp != null) {
    first=tmp.nextEvent;
    tmp.nextEvent=null;
  }
  if (first != null) {
    nextTime=first.time;
  }
 else {
    nextTime=0;
  }
  tmp.scheduledIn=null;
  eventCount--;
  return tmp;
}

Fixed version (ground truth):
public TimeEvent popFirst(){
  TimeEvent tmp=first;
  if (tmp != null) {
    first=tmp.nextEvent;
    tmp.nextEvent=null;
    tmp.scheduledIn=null;
  }
  if (first != null) {
    nextTime=first.time;
  }
 else {
    nextTime=0;
  }
  eventCount--;
  return tmp;
}