Program: 25446
Project: 25446
Buggy source:
private void handleFlowStatsRequest(OFMessage msg){
  log.debug("String_Node_Str" + mySwitch.getStringId() + "String_Node_Str");
  List<OFStatistics> results=this.parent.getSlicedFlowStats(mySwitch.getId(),this.mySlicer.getSliceName());
  if (results == null) {
    log.debug("String_Node_Str");
    return;
  }
  log.debug("String_Node_Str" + results.toString());
  this.flowCount=results.size();
  if (results.size() <= 0) {
    OFStatisticsReply reply=new OFStatisticsReply();
    reply.setStatistics(results);
    reply.setStatisticType(OFStatisticsType.FLOW);
    reply.setXid(msg.getXid());
    reply.setFlags((short)0x0000);
    try {
      ofcch.sendMessage(reply);
    }
 catch (    IOException e1) {
      e1.printStackTrace();
    }
    return;
  }
  short length=0;
  int counter=0;
  Iterator<OFStatistics> it2=results.iterator();
  List<OFFlowStatisticsReply> limitedResults=new ArrayList<OFFlowStatisticsReply>();
  while (it2.hasNext()) {
    OFFlowStatisticsReply stat=(OFFlowStatisticsReply)it2.next();
    if (this.mySlicer.getTagManagement()) {
      stat.getMatch().setDataLayerVirtualLan((short)0);
      stat.getMatch().setWildcards(stat.getMatch().getWildcardObj().wildcard(Wildcards.Flag.DL_VLAN));
      List<OFAction> newActions=new ArrayList<OFAction>();
      short actLength=0;
      List<OFAction> actions=stat.getActions();
      Iterator<OFAction> actIt=actions.iterator();
      while (actIt.hasNext()) {
        OFAction act=actIt.next();
switch (act.getType()) {
case SET_VLAN_ID:
          break;
case SET_VLAN_PCP:
        break;
case STRIP_VLAN:
      break;
default :
    newActions.add(act);
  actLength+=act.getLength();
break;
}
}
stat.setActions(newActions);
stat.setLength((short)(OFFlowStatisticsReply.MINIMUM_LENGTH + actLength));
}
length+=stat.getLength();
counter++;
limitedResults.add(stat);
if (counter >= 10 || it2.hasNext() == false) {
OFStatisticsReply reply=new OFStatisticsReply();
reply.setStatistics(limitedResults);
reply.setStatisticType(OFStatisticsType.FLOW);
reply.setXid(msg.getXid());
if (it2.hasNext() == false) {
reply.setFlags((short)0x0000);
}
 else {
reply.setFlags((short)0x0001);
}
length+=reply.getLength();
reply.setLength(length);
try {
ofcch.sendMessage(reply);
}
 catch (IOException e1) {
e1.printStackTrace();
}
counter=0;
length=0;
limitedResults=new ArrayList<OFFlowStatisticsReply>();
}
}
}

Fixed version (ground truth):
private void handleFlowStatsRequest(OFMessage msg){
  log.debug("String_Node_Str" + mySwitch.getStringId() + "String_Node_Str");
  List<OFStatistics> results=this.parent.getSlicedFlowStats(mySwitch.getId(),this.mySlicer.getSliceName());
  if (results == null) {
    log.debug("String_Node_Str");
    return;
  }
  log.debug("String_Node_Str" + results.toString());
  this.flowCount=results.size();
  if (results.size() <= 0) {
    OFStatisticsReply reply=new OFStatisticsReply();
    reply.setStatistics(results);
    reply.setStatisticType(OFStatisticsType.FLOW);
    reply.setXid(msg.getXid());
    reply.setFlags((short)0x0000);
    try {
      ofcch.sendMessage(reply);
    }
 catch (    IOException e1) {
      e1.printStackTrace();
    }
    return;
  }
  short length=0;
  int counter=0;
  Iterator<OFStatistics> it2=results.iterator();
  List<OFFlowStatisticsReply> limitedResults=new ArrayList<OFFlowStatisticsReply>();
  while (it2.hasNext()) {
    OFFlowStatisticsReply stat=(OFFlowStatisticsReply)it2.next();
    if (this.mySlicer.getTagManagement()) {
      OFFlowStatisticsReply newStat=new OFFlowStatisticsReply();
      newStat.setMatch(stat.getMatch().clone());
      newStat.getMatch().setDataLayerVirtualLan((short)0);
      newStat.getMatch().setWildcards(newStat.getMatch().getWildcardObj().wildcard(Wildcards.Flag.DL_VLAN));
      List<OFAction> newActions=new ArrayList<OFAction>();
      short actLength=0;
      List<OFAction> actions=stat.getActions();
      Iterator<OFAction> actIt=actions.iterator();
      while (actIt.hasNext()) {
        OFAction act=actIt.next();
switch (act.getType()) {
case SET_VLAN_ID:
          break;
case SET_VLAN_PCP:
        break;
case STRIP_VLAN:
      break;
default :
    newActions.add(act);
  actLength+=act.getLength();
break;
}
}
newStat.setActions(newActions);
newStat.setLength((short)(OFFlowStatisticsReply.MINIMUM_LENGTH + actLength));
stat=newStat;
}
length+=stat.getLength();
counter++;
limitedResults.add(stat);
if (counter >= 10 || it2.hasNext() == false) {
OFStatisticsReply reply=new OFStatisticsReply();
reply.setStatistics(limitedResults);
reply.setStatisticType(OFStatisticsType.FLOW);
reply.setXid(msg.getXid());
if (it2.hasNext() == false) {
reply.setFlags((short)0x0000);
}
 else {
reply.setFlags((short)0x0001);
}
length+=reply.getLength();
reply.setLength(length);
try {
ofcch.sendMessage(reply);
}
 catch (IOException e1) {
e1.printStackTrace();
}
counter=0;
length=0;
limitedResults=new ArrayList<OFFlowStatisticsReply>();
}
}
}