nus-yam/ex-repair huggingface dataset:
Program: 61628
Project: 61628
Buggy source:
public GlyphType(GFxInputStream sis) throws IOException {
  boundingBox=new int[4];
  for (int i=0; i < 4; i++) {
    boundingBox[i]=sis.readSI15("String_Node_Str");
  }
  int numContours=sis.readUI15("String_Node_Str");
  contours=new ContourType[numContours];
  for (int i=0; i < numContours; i++) {
    sis.newDumpLevel("String_Node_Str","String_Node_Str");
    contours[i]=new ContourType(sis);
    sis.endDumpLevel();
  }
}

Fixed version (ground truth):
public GlyphType(GFxInputStream sis,long fontOffset) throws IOException {
  boundingBox=new int[4];
  for (int i=0; i < 4; i++) {
    boundingBox[i]=sis.readSI15("String_Node_Str");
  }
  int numContours=sis.readUI15("String_Node_Str");
  contours=new ContourType[numContours];
  for (int i=0; i < numContours; i++) {
    sis.newDumpLevel("String_Node_Str","String_Node_Str");
    contours[i]=new ContourType(sis,fontOffset);
    sis.endDumpLevel();
  }
}
Program: 61629
Project: 61629
Buggy source:
private String readString(InputStream is) throws IOException {
  int len=is.read();
  if (len == -1) {
    return "String_Node_Str";
  }
  byte buf[]=new byte[len];
  is.read(buf);
  return new String(buf,"String_Node_Str");
}

Fixed version (ground truth):
private String readString(InputStream is) throws IOException {
  int len=is.read();
  if (len == -1) {
    throw new EOFException();
  }
  byte buf[]=new byte[len];
  for (int i=0; i < len; i++) {
    int rd=is.read();
    if (rd == -1) {
      throw new EOFException();
    }
    buf[i]=(byte)rd;
  }
  return new String(buf,"String_Node_Str");
}
Program: 61634
Project: 61634
Buggy source:
public void replaceSciptPack(ScriptPack pack,String as) throws AVM2ParseException, CompilationException, IOException, InterruptedException {
  String scriptName=pack.getPathScriptName() + "String_Node_Str";
  int oldIndex=pack.scriptIndex;
  int newIndex=script_info.size();
  String documentClass="String_Node_Str";
  loopt:   for (  Tag t : swf.tags) {
    if (t instanceof SymbolClassTag) {
      SymbolClassTag sc=(SymbolClassTag)t;
      for (int i=0; i < sc.tags.length; i++) {
        if (sc.tags[i] == 0) {
          documentClass=sc.names[i];
          break loopt;
        }
      }
    }
  }
  boolean isDocumentClass=documentClass.equals(pack.getPath().toString());
  script_info.get(oldIndex).delete(this,true);
  ActionScriptParser.compile(as,this,new ArrayList<ABC>(),isDocumentClass,scriptName);
  script_info.set(oldIndex,script_info.get(newIndex));
  script_info.remove(newIndex);
  pack();
  ((Tag)parentTag).setModified(true);
}

Fixed version (ground truth):
public void replaceSciptPack(ScriptPack pack,String as) throws AVM2ParseException, CompilationException, IOException, InterruptedException {
  String scriptName=pack.getPathScriptName() + "String_Node_Str";
  int oldIndex=pack.scriptIndex;
  int newIndex=script_info.size();
  String documentClass="String_Node_Str";
  loopt:   for (  Tag t : swf.tags) {
    if (t instanceof SymbolClassTag) {
      SymbolClassTag sc=(SymbolClassTag)t;
      for (int i=0; i < sc.tags.length; i++) {
        if (sc.tags[i] == 0) {
          documentClass=sc.names[i];
          break loopt;
        }
      }
    }
  }
  boolean isDocumentClass=documentClass.equals(pack.getPath().toString());
  ScriptInfo si=script_info.get(oldIndex);
  si.delete(this,true);
  int newClassIndex=instance_info.size();
  for (  Trait t : si.traits.traits) {
    if (t instanceof TraitClass) {
      TraitClass tc=(TraitClass)t;
      newClassIndex=tc.class_info + 1;
    }
  }
  ActionScriptParser.compile(as,this,new ArrayList<ABC>(),isDocumentClass,scriptName,newClassIndex);
  script_info.set(oldIndex,script_info.get(newIndex));
  script_info.remove(newIndex);
  pack();
  ((Tag)parentTag).setModified(true);
}
Program: 61638
Project: 61638
Buggy source:
public int generateClass(int namespace,ClassInfo ci,InstanceInfo ii,int initScope,String pkg,SourceGeneratorLocalData localData,AVM2Item cls) throws AVM2ParseException, CompilationException {
  if (cls instanceof ClassAVM2Item) {
    ClassAVM2Item cai=(ClassAVM2Item)cls;
    generateClass(cai.importedClasses,cai.sinitVariables,cai.staticInitActivation,cai.staticInit,cai.openedNamespaces,namespace,initScope,pkg,ci,ii,localData,false,cai.className,cai.extendsOp == null ? "String_Node_Str" : cai.extendsOp.toString(),cai.extendsOp,cai.implementsOp,cai.constructor,cai.traits);
    if (!cai.isDynamic) {
      ii.flags|=InstanceInfo.CLASS_SEALED;
    }
    if (cai.isFinal) {
      ii.flags|=InstanceInfo.CLASS_FINAL;
    }
    ii.flags|=InstanceInfo.CLASS_PROTECTEDNS;
    ii.protectedNS=cai.protectedNs;
  }
  if (cls instanceof InterfaceAVM2Item) {
    InterfaceAVM2Item iai=(InterfaceAVM2Item)cls;
    ii.flags|=InstanceInfo.CLASS_INTERFACE;
    ii.flags|=InstanceInfo.CLASS_SEALED;
    generateClass(iai.importedClasses,new ArrayList<AssignableAVM2Item>(),false,new ArrayList<GraphTargetItem>(),iai.openedNamespaces,namespace,initScope,pkg,ci,ii,localData,true,iai.name,null,null,iai.superInterfaces,null,iai.methods);
  }
  return abc.instance_info.size() - 1;
}

Fixed version (ground truth):
public int generateClass(int namespace,ClassInfo ci,InstanceInfo ii,int initScope,String pkg,SourceGeneratorLocalData localData,AVM2Item cls,Reference<Integer> class_index) throws AVM2ParseException, CompilationException {
  if (cls instanceof ClassAVM2Item) {
    ClassAVM2Item cai=(ClassAVM2Item)cls;
    generateClass(cai.importedClasses,cai.sinitVariables,cai.staticInitActivation,cai.staticInit,cai.openedNamespaces,namespace,initScope,pkg,ci,ii,localData,false,cai.className,cai.extendsOp == null ? "String_Node_Str" : cai.extendsOp.toString(),cai.extendsOp,cai.implementsOp,cai.constructor,cai.traits,class_index);
    if (!cai.isDynamic) {
      ii.flags|=InstanceInfo.CLASS_SEALED;
    }
    if (cai.isFinal) {
      ii.flags|=InstanceInfo.CLASS_FINAL;
    }
    ii.flags|=InstanceInfo.CLASS_PROTECTEDNS;
    ii.protectedNS=cai.protectedNs;
  }
  if (cls instanceof InterfaceAVM2Item) {
    InterfaceAVM2Item iai=(InterfaceAVM2Item)cls;
    ii.flags|=InstanceInfo.CLASS_INTERFACE;
    ii.flags|=InstanceInfo.CLASS_SEALED;
    generateClass(iai.importedClasses,new ArrayList<AssignableAVM2Item>(),false,new ArrayList<GraphTargetItem>(),iai.openedNamespaces,namespace,initScope,pkg,ci,ii,localData,true,iai.name,null,null,iai.superInterfaces,null,iai.methods,class_index);
  }
  return abc.instance_info.size() - 1;
}
Program: 61639
Project: 61639
Buggy source:
public void addScriptFromTree(List<GraphTargetItem> items,boolean documentClass) throws AVM2ParseException, CompilationException {
  AVM2SourceGenerator gen=new AVM2SourceGenerator(abc,otherABCs);
  List<AVM2Instruction> ret=new ArrayList<>();
  SourceGeneratorLocalData localData=new SourceGeneratorLocalData(new HashMap<String,Integer>(),0,Boolean.FALSE,0);
  localData.documentClass=documentClass;
  abc.script_info.add(gen.generateScriptInfo(localData,items));
}

Fixed version (ground truth):
public void addScriptFromTree(List<GraphTargetItem> items,boolean documentClass,int classPos) throws AVM2ParseException, CompilationException {
  AVM2SourceGenerator gen=new AVM2SourceGenerator(abc,otherABCs);
  List<AVM2Instruction> ret=new ArrayList<>();
  SourceGeneratorLocalData localData=new SourceGeneratorLocalData(new HashMap<String,Integer>(),0,Boolean.FALSE,0);
  localData.documentClass=documentClass;
  abc.script_info.add(gen.generateScriptInfo(localData,items,classPos));
}
Program: 61640
Project: 61640
Buggy source:
public void addScript(String s,boolean documentClass,String fileName) throws AVM2ParseException, IOException, CompilationException {
  List<GraphTargetItem> traits=scriptTraitsFromString(s,fileName);
  addScriptFromTree(traits,documentClass);
}

Fixed version (ground truth):
public void addScript(String s,boolean documentClass,String fileName,int classPos) throws AVM2ParseException, IOException, CompilationException {
  List<GraphTargetItem> traits=scriptTraitsFromString(s,fileName);
  addScriptFromTree(traits,documentClass,classPos);
}
Program: 61641
Project: 61641
Buggy source:
public static void compile(SWF swf,String src,String dst){
  System.err.println("String_Node_Str");
  try {
    initPlayer();
    ABC abc=new ABC(swf);
    ActionScriptParser parser=new ActionScriptParser(abc,playerABCs);
    parser.addScript(new String(Helper.readFile(src),"String_Node_Str"),true,src);
    abc.saveToStream(new FileOutputStream(new File(dst)));
  }
 catch (  Exception ex) {
    Logger.getLogger(ActionScriptParser.class.getName()).log(Level.SEVERE,null,ex);
  }
  System.exit(0);
}

Fixed version (ground truth):
public static void compile(SWF swf,String src,String dst,int classPos){
  System.err.println("String_Node_Str");
  try {
    initPlayer();
    ABC abc=new ABC(swf);
    ActionScriptParser parser=new ActionScriptParser(abc,playerABCs);
    parser.addScript(new String(Helper.readFile(src),"String_Node_Str"),true,src,classPos);
    abc.saveToStream(new FileOutputStream(new File(dst)));
  }
 catch (  Exception ex) {
    Logger.getLogger(ActionScriptParser.class.getName()).log(Level.SEVERE,null,ex);
  }
  System.exit(0);
}
Program: 61644
Project: 61644
Buggy source:
public TextPanel(MainPanel mainPanel){
  super(new BorderLayout());
  this.mainPanel=mainPanel;
  textSearchPanel=new SearchPanel<>(new FlowLayout(),mainPanel);
  add(textSearchPanel,BorderLayout.NORTH);
  textValue=new LineMarkedEditorPane();
  add(new JScrollPane(textValue),BorderLayout.CENTER);
  textValue.setEditable(false);
  JPanel textButtonsPanel=new JPanel();
  textButtonsPanel.setLayout(new FlowLayout());
  textSaveButton=new JButton(mainPanel.translate("String_Node_Str"),View.getIcon("String_Node_Str"));
  textSaveButton.setMargin(new Insets(3,3,3,10));
  textSaveButton.setActionCommand(ACTION_SAVE_TEXT);
  textSaveButton.addActionListener(this);
  textEditButton=new JButton(mainPanel.translate("String_Node_Str"),View.getIcon("String_Node_Str"));
  textEditButton.setMargin(new Insets(3,3,3,10));
  textEditButton.setActionCommand(ACTION_EDIT_TEXT);
  textEditButton.addActionListener(this);
  textCancelButton=new JButton(mainPanel.translate("String_Node_Str"),View.getIcon("String_Node_Str"));
  textCancelButton.setMargin(new Insets(3,3,3,10));
  textCancelButton.setActionCommand(ACTION_CANCEL_TEXT);
  textCancelButton.addActionListener(this);
  textButtonsPanel.add(textEditButton);
  textButtonsPanel.add(textSaveButton);
  textButtonsPanel.add(textCancelButton);
  textSaveButton.setVisible(false);
  textCancelButton.setVisible(false);
  add(textButtonsPanel,BorderLayout.SOUTH);
}

Fixed version (ground truth):
public TextPanel(MainPanel mainPanel){
  super(new BorderLayout());
  DefaultSyntaxKit.initKit();
  this.mainPanel=mainPanel;
  textSearchPanel=new SearchPanel<>(new FlowLayout(),mainPanel);
  add(textSearchPanel,BorderLayout.NORTH);
  textValue=new LineMarkedEditorPane();
  add(new JScrollPane(textValue),BorderLayout.CENTER);
  textValue.setEditable(false);
  JPanel textButtonsPanel=new JPanel();
  textButtonsPanel.setLayout(new FlowLayout());
  textSaveButton=new JButton(mainPanel.translate("String_Node_Str"),View.getIcon("String_Node_Str"));
  textSaveButton.setMargin(new Insets(3,3,3,10));
  textSaveButton.setActionCommand(ACTION_SAVE_TEXT);
  textSaveButton.addActionListener(this);
  textEditButton=new JButton(mainPanel.translate("String_Node_Str"),View.getIcon("String_Node_Str"));
  textEditButton.setMargin(new Insets(3,3,3,10));
  textEditButton.setActionCommand(ACTION_EDIT_TEXT);
  textEditButton.addActionListener(this);
  textCancelButton=new JButton(mainPanel.translate("String_Node_Str"),View.getIcon("String_Node_Str"));
  textCancelButton.setMargin(new Insets(3,3,3,10));
  textCancelButton.setActionCommand(ACTION_CANCEL_TEXT);
  textCancelButton.addActionListener(this);
  textButtonsPanel.add(textEditButton);
  textButtonsPanel.add(textSaveButton);
  textButtonsPanel.add(textCancelButton);
  textSaveButton.setVisible(false);
  textCancelButton.setVisible(false);
  add(textButtonsPanel,BorderLayout.SOUTH);
}
Program: 61645
Project: 61645
Buggy source:
public String getStringUnderCursor(){
  int pos=decompiledEditor.getCaretPosition();
  Highlighting h=Highlighting.search(decompiledHilights,pos);
  if (h != null) {
    List<Action> list=lastCode;
    Action lastIns=null;
    int inspos=0;
    Action selIns=null;
    for (    Action ins : list) {
      if (h.getPropertyLong("String_Node_Str") == ins.getOffset()) {
        selIns=ins;
        break;
      }
      if (ins.getOffset() > h.getPropertyLong("String_Node_Str")) {
        inspos=(int)(h.getPropertyLong("String_Node_Str") - lastIns.getAddress());
        selIns=lastIns;
        break;
      }
      lastIns=ins;
    }
    if (selIns != null) {
      if (selIns instanceof ActionPush) {
        ActionPush ap=(ActionPush)selIns;
        Object var=ap.values.get(inspos - 1);
        String identifier=null;
        if (var instanceof String) {
          identifier=(String)var;
        }
        if (var instanceof ConstantIndex) {
          identifier=ap.constantPool.get(((ConstantIndex)var).index);
        }
        return identifier;
      }
    }
  }
  return null;
}

Fixed version (ground truth):
public String getStringUnderCursor(){
  int pos=decompiledEditor.getCaretPosition();
  SyntaxDocument sDoc=ActionUtils.getSyntaxDocument(decompiledEditor);
  if (sDoc != null) {
    Token t=sDoc.getTokenAt(pos);
    String ident=null;
    if (t != null && (t.type == TokenType.IDENTIFIER || t.type == TokenType.REGEX)) {
      CharSequence tData=t.getText(sDoc);
      ident=tData.toString();
      ActionScriptLexer lex=new ActionScriptLexer(new StringReader(ident));
      try {
        ParsedSymbol symb=lex.lex();
        if (symb.type == SymbolType.IDENTIFIER) {
          ident=(String)symb.value;
        }
 else {
          ident=null;
        }
      }
 catch (      IOException|ActionParseException ex) {
        ident=null;
      }
    }
    if (ident == null) {
      Highlighting h=Highlighting.search(decompiledHilights,pos);
      if (h != null) {
        List<Action> list=lastCode;
        Action lastIns=null;
        int inspos=0;
        Action selIns=null;
        for (        Action ins : list) {
          if (h.getPropertyLong("String_Node_Str") == ins.getOffset()) {
            selIns=ins;
            break;
          }
          if (ins.getOffset() > h.getPropertyLong("String_Node_Str")) {
            inspos=(int)(h.getPropertyLong("String_Node_Str") - lastIns.getAddress());
            selIns=lastIns;
            break;
          }
          lastIns=ins;
        }
        if (selIns != null) {
          if (selIns instanceof ActionPush) {
            ActionPush ap=(ActionPush)selIns;
            Object var=ap.values.get(inspos - 1);
            String identifier=null;
            if (var instanceof String) {
              identifier=(String)var;
            }
            if (var instanceof ConstantIndex) {
              identifier=ap.constantPool.get(((ConstantIndex)var).index);
            }
            return identifier;
          }
        }
      }
    }
 else {
      return ident;
    }
  }
  return null;
}
Program: 61647
Project: 61647
Buggy source:
public boolean isKilled(int regName,int start,int end){
  for (int k=start; k <= end; k++) {
    if (code.get(k).definition instanceof KillIns) {
      if (code.get(k).operands[0] == regName) {
        return true;
      }
    }
  }
  return false;
}

Fixed version (ground truth):
/** 
 * Test for killed register. CalcKilledStats must be called before
 * @param regName
 * @param start
 * @param end
 * @return 
 */
public boolean isKilled(int regName,int start,int end){
  return killedRegs.contains(regName);
}
Program: 61649
Project: 61649
Buggy source:
@Override public byte[] getRawSoundData(){
  if (soundFormat == SoundFormat.FORMAT_MP3) {
    return Arrays.copyOfRange(soundData,2,soundData.length);
  }
  return soundData;
}

Fixed version (ground truth):
@Override public List<byte[]> getRawSoundData(){
  List<byte[]> ret=new ArrayList<byte[]>();
  if (soundFormat == SoundFormat.FORMAT_MP3) {
    ret.add(Arrays.copyOfRange(soundData,2,soundData.length));
    return ret;
  }
  ret.add(soundData);
  return ret;
}
Program: 61650
Project: 61650
Buggy source:
@Override public List<SoundStreamBlockTag> getBlocks(){
  List<SoundStreamBlockTag> ret=new ArrayList<>();
  SoundStreamHeadTag.populateSoundStreamBlocks(swf.tags,this,ret);
  return ret;
}

Fixed version (ground truth):
@Override public List<SoundStreamBlockTag> getBlocks(){
  List<SoundStreamBlockTag> ret=new ArrayList<>();
  SoundStreamHeadTag.populateSoundStreamBlocks(0,swf.tags,this,ret);
  return ret;
}
Program: 61651
Project: 61651
Buggy source:
@Override public byte[] getRawSoundData(){
  List<SoundStreamBlockTag> blocks=getBlocks();
  ByteArrayOutputStream baos=new ByteArrayOutputStream();
  try {
    for (    SoundStreamBlockTag block : blocks) {
      if (streamSoundCompression == SoundFormat.FORMAT_MP3) {
        baos.write(block.streamSoundData,4,block.streamSoundData.length - 4);
      }
 else {
        baos.write(block.streamSoundData);
      }
    }
  }
 catch (  IOException ex) {
    return null;
  }
  return baos.toByteArray();
}

Fixed version (ground truth):
@Override public List<byte[]> getRawSoundData(){
  List<byte[]> ret=new ArrayList<byte[]>();
  List<SoundStreamBlockTag> blocks=getBlocks();
  for (  SoundStreamBlockTag block : blocks) {
    if (streamSoundCompression == SoundFormat.FORMAT_MP3) {
      ret.add(Arrays.copyOfRange(block.streamSoundData,4,block.streamSoundData.length));
    }
 else {
      ret.add(block.streamSoundData);
    }
  }
  return ret;
}
Program: 61652
Project: 61652
Buggy source:
@Override public List<SoundStreamBlockTag> getBlocks(){
  List<SoundStreamBlockTag> ret=new ArrayList<>();
  populateSoundStreamBlocks(swf.tags,this,ret);
  return ret;
}

Fixed version (ground truth):
@Override public List<SoundStreamBlockTag> getBlocks(){
  List<SoundStreamBlockTag> ret=new ArrayList<>();
  populateSoundStreamBlocks(0,swf.tags,this,ret);
  return ret;
}
Program: 61653
Project: 61653
Buggy source:
public static void populateSoundStreamBlocks(List<? extends ContainerItem> tags,Tag head,List<SoundStreamBlockTag> output){
  boolean found=false;
  for (  ContainerItem t : tags) {
    if (t == head) {
      found=true;
      continue;
    }
    if (!found) {
      continue;
    }
    if (t instanceof SoundStreamBlockTag) {
      output.add((SoundStreamBlockTag)t);
    }
    if (t instanceof SoundStreamHeadTypeTag) {
      break;
    }
    if (t instanceof Container) {
      populateSoundStreamBlocks(((Container)t).getSubItems(),head,output);
    }
  }
}

Fixed version (ground truth):
public static void populateSoundStreamBlocks(int containerId,List<? extends ContainerItem> tags,Tag head,List<SoundStreamBlockTag> output){
  boolean found=false;
  for (  ContainerItem t : tags) {
    if (t == head) {
      found=true;
      ((SoundStreamHeadTypeTag)head).setVirtualCharacterId(containerId);
      continue;
    }
    if (t instanceof Container) {
      populateSoundStreamBlocks(((CharacterIdTag)t).getCharacterId(),((Container)t).getSubItems(),head,output);
    }
    if (!found) {
      continue;
    }
    if (t instanceof SoundStreamBlockTag) {
      output.add((SoundStreamBlockTag)t);
    }
    if (t instanceof SoundStreamHeadTypeTag) {
      break;
    }
  }
}
Program: 61654
Project: 61654
Buggy source:
@Override public byte[] getRawSoundData(){
  List<SoundStreamBlockTag> blocks=getBlocks();
  ByteArrayOutputStream baos=new ByteArrayOutputStream();
  try {
    for (    SoundStreamBlockTag block : blocks) {
      if (streamSoundCompression == SoundFormat.FORMAT_MP3) {
        baos.write(block.streamSoundData,4,block.streamSoundData.length - 4);
      }
 else {
        baos.write(block.streamSoundData);
      }
    }
  }
 catch (  IOException ex) {
    return null;
  }
  return baos.toByteArray();
}

Fixed version (ground truth):
@Override public List<byte[]> getRawSoundData(){
  List<byte[]> ret=new ArrayList<byte[]>();
  List<SoundStreamBlockTag> blocks=getBlocks();
  for (  SoundStreamBlockTag block : blocks) {
    if (streamSoundCompression == SoundFormat.FORMAT_MP3) {
      ret.add(Arrays.copyOfRange(block.streamSoundData,4,block.streamSoundData.length));
    }
 else {
      ret.add(block.streamSoundData);
    }
  }
  return ret;
}
Program: 61655
Project: 61655
Buggy source:
public byte[] getRawSoundData();

Fixed version (ground truth):
public List<byte[]> getRawSoundData();
Program: 61656
Project: 61656
Buggy source:
public boolean createWav(SWFInputStream sis,OutputStream os){
  ensureFormat();
  ByteArrayOutputStream baos=new ByteArrayOutputStream();
  decode(sis,baos);
  try {
    createWavFromPcmData(os,samplingRate,true,stereo,baos.toByteArray());
    return true;
  }
 catch (  IOException ex) {
    return false;
  }
}

Fixed version (ground truth):
public boolean createWav(List<SWFInputStream> siss,OutputStream os){
  ensureFormat();
  ByteArrayOutputStream baos=new ByteArrayOutputStream();
  for (  SWFInputStream sis : siss) {
    decode(sis,baos);
  }
  try {
    createWavFromPcmData(os,samplingRate,true,stereo,baos.toByteArray());
    return true;
  }
 catch (  IOException ex) {
    return false;
  }
}
Program: 61657
Project: 61657
Buggy source:
public SoundTagPlayer(SoundTag tag,int loops) throws LineUnavailableException, IOException, UnsupportedAudioFileException {
  this.tag=tag;
  this.loops=loops;
  ByteArrayOutputStream baos=new ByteArrayOutputStream();
  byte[] soundData=tag.getRawSoundData();
  SWF swf=((Tag)tag).getSwf();
  tag.getSoundFormat().createWav(new SWFInputStream(swf,soundData),baos);
  player=new SoundPlayer(new ByteArrayInputStream(baos.toByteArray()));
}

Fixed version (ground truth):
public SoundTagPlayer(SoundTag tag,int loops) throws LineUnavailableException, IOException, UnsupportedAudioFileException {
  this.tag=tag;
  this.loops=loops;
  ByteArrayOutputStream baos=new ByteArrayOutputStream();
  List<byte[]> soundData=tag.getRawSoundData();
  SWF swf=((Tag)tag).getSwf();
  List<SWFInputStream> siss=new ArrayList<>();
  for (  byte[] data : soundData) {
    siss.add(new SWFInputStream(swf,data));
  }
  tag.getSoundFormat().createWav(siss,baos);
  player=new SoundPlayer(new ByteArrayInputStream(baos.toByteArray()));
}
Program: 61659
Project: 61659
Buggy source:
public static void copyStream(InputStream is,OutputStream os,long maxLength){
  try {
    final int bufSize=4096;
    byte[] buf=new byte[bufSize];
    int cnt=0;
    while ((cnt=is.read(buf)) > 0) {
      os.write(buf,0,cnt);
      maxLength-=cnt;
      if (maxLength < bufSize) {
        buf=new byte[(int)maxLength];
      }
    }
  }
 catch (  IOException ex) {
    Logger.getLogger(Helper.class.getName()).log(Level.SEVERE,null,ex);
  }
}

Fixed version (ground truth):
public static void copyStream(InputStream is,OutputStream os,long maxLength){
  try {
    final int bufSize=4096;
    byte[] buf=new byte[bufSize];
    int cnt=0;
    while ((cnt=is.read(buf)) > 0) {
      os.write(buf,0,cnt);
      maxLength-=cnt;
      if (maxLength < bufSize) {
        buf=new byte[(int)maxLength];
      }
    }
  }
 catch (  IOException ex) {
  }
}
Program: 61662
Project: 61662
Buggy source:
public FontType(GFxInputStream sis) throws IOException {
  fontName=sis.readString();
  flags=sis.readUI16();
  nominalSize=sis.readUI16();
  ascent=sis.readSI16();
  descent=sis.readSI16();
  leading=sis.readSI16();
  long numGlyphs=sis.readUI32();
  long glyphBytesLen=sis.readUI32();
  byte glyphBytes[]=new byte[(int)glyphBytesLen];
  sis.read(glyphBytes);
  glyphInfo=new ArrayList<>();
  for (int i=0; i < numGlyphs; i++) {
    glyphInfo.add(new GlyphInfoType(sis));
  }
  long kerningTableSize=sis.readUI30();
  kerning=new ArrayList<>();
  for (int i=0; i < kerningTableSize; i++) {
    kerning.add(new KerningPairType(sis));
  }
  glyphs=new ArrayList<>();
  for (int i=0; i < glyphInfo.size(); i++) {
    sis.setPos(glyphInfo.get(i).globalOffset);
    glyphs.add(new GlyphType(sis));
  }
}

Fixed version (ground truth):
public FontType(GFxInputStream sis) throws IOException {
  fontName=sis.readString();
  flags=sis.readUI16();
  nominalSize=sis.readUI16();
  ascent=sis.readSI16();
  descent=sis.readSI16();
  leading=sis.readSI16();
  long numGlyphs=sis.readUI32();
  long glyphBytesLen=sis.readUI32();
  byte glyphBytes[]=new byte[(int)glyphBytesLen];
  sis.read(glyphBytes);
  glyphInfo=new ArrayList<>();
  for (int i=0; i < numGlyphs; i++) {
    glyphInfo.add(new GlyphInfoType(sis));
  }
  long kerningTableSize=sis.readUI30();
  kerning=new ArrayList<>();
  for (int i=0; i < kerningTableSize; i++) {
    kerning.add(new KerningPairType(sis));
  }
  long pos=sis.getPos();
  glyphs=new ArrayList<>();
  for (int i=0; i < glyphInfo.size(); i++) {
    sis.setPos(glyphInfo.get(i).globalOffset);
    glyphs.add(new GlyphType(sis));
  }
  sis.setPos(pos);
}
Program: 61663
Project: 61663
Buggy source:
/** 
 * Reads one string value from the stream
 * @param name
 * @return String value
 * @throws IOException
 */
public String readString() throws IOException {
  ByteArrayOutputStream baos=new ByteArrayOutputStream();
  int r;
  while (true) {
    r=readUI8();
    if (r == 0) {
      return new String(baos.toByteArray(),Utf8Helper.charset);
    }
    baos.write(r);
  }
}

Fixed version (ground truth):
/** 
 * Reads one string value from the stream
 * @return String value
 * @throws IOException
 */
public String readString() throws IOException {
  ByteArrayOutputStream baos=new ByteArrayOutputStream();
  int r;
  while (true) {
    r=readUI8();
    if (r == 0) {
      return new String(baos.toByteArray(),Utf8Helper.charset);
    }
    baos.write(r);
  }
}
Program: 61670
Project: 61670
Buggy source:
@Override public void setActions(List<Action> actions){
  actionBytes=Action.actionsToBytes(actions,true,swf.version);
}

Fixed version (ground truth):
@Override public void setActions(List<Action> actions){
  byte[] bytes=Action.actionsToBytes(actions,true,swf.version);
  actionBytes=new ByteArrayRange(bytes,0,bytes.length);
}
Program: 61671
Project: 61671
Buggy source:
@Override public GraphTextWriter getActionBytesAsHex(GraphTextWriter writer){
  return Helper.byteArrayToHexWithHeader(writer,actionBytes);
}

Fixed version (ground truth):
@Override public GraphTextWriter getActionBytesAsHex(GraphTextWriter writer){
  return Helper.byteArrayToHexWithHeader(writer,actionBytes.getRangeData());
}
Program: 61672
Project: 61672
Buggy source:
/** 
 * Returns actions associated with this object
 * @return List of actions
 * @throws java.lang.InterruptedException
 */
@Override public List<Action> getActions() throws InterruptedException {
  try {
    int prevLength;
    SWFInputStream rri;
    if (actionBytes == null) {
      prevLength=(int)(getDataPos() + hdrSize);
      rri=new SWFInputStream(swf,getOriginalRange().array);
      rri.seek(prevLength);
    }
 else {
      prevLength=0;
      rri=new SWFInputStream(swf,actionBytes);
    }
    List<Action> list=ActionListReader.readActionListTimeout(listeners,rri,getVersion(),prevLength,-1,toString());
    return list;
  }
 catch (  InterruptedException ex) {
    throw ex;
  }
catch (  Exception ex) {
    Logger.getLogger(DoActionTag.class.getName()).log(Level.SEVERE,null,ex);
    return new ArrayList<>();
  }
}

Fixed version (ground truth):
/** 
 * Returns actions associated with this object
 * @return List of actions
 * @throws java.lang.InterruptedException
 */
@Override public List<Action> getActions() throws InterruptedException {
  try {
    int prevLength=actionBytes.pos;
    SWFInputStream rri=new SWFInputStream(swf,actionBytes.array);
    if (prevLength != 0) {
      rri.seek(prevLength);
    }
    List<Action> list=ActionListReader.readActionListTimeout(listeners,rri,getVersion(),prevLength,-1,toString());
    return list;
  }
 catch (  InterruptedException ex) {
    throw ex;
  }
catch (  Exception ex) {
    Logger.getLogger(DoActionTag.class.getName()).log(Level.SEVERE,null,ex);
    return new ArrayList<>();
  }
}
Program: 61673
Project: 61673
Buggy source:
/** 
 * Constructor
 * @param sis
 * @param data
 * @throws IOException
 */
public DefineButtonTag(SWFInputStream sis,ByteArrayRange data) throws IOException {
  super(sis.getSwf(),ID,"String_Node_Str",data);
  buttonId=sis.readUI16("String_Node_Str");
  characters=sis.readBUTTONRECORDList(false,"String_Node_Str");
  hdrSize=sis.getPos();
  actionBytes=sis.readBytesEx(sis.available(),"String_Node_Str");
}

Fixed version (ground truth):
/** 
 * Constructor
 * @param sis
 * @param data
 * @throws IOException
 */
public DefineButtonTag(SWFInputStream sis,ByteArrayRange data) throws IOException {
  super(sis.getSwf(),ID,"String_Node_Str",data);
  buttonId=sis.readUI16("String_Node_Str");
  characters=sis.readBUTTONRECORDList(false,"String_Node_Str");
  int pos=(int)sis.getPos();
  byte[] bytes=sis.readBytesEx(sis.available(),"String_Node_Str");
  actionBytes=new ByteArrayRange(data.array,pos,bytes.length);
}
Program: 61674
Project: 61674
Buggy source:
@Override public void setActionBytes(byte[] actionBytes){
  this.actionBytes=actionBytes;
}

Fixed version (ground truth):
@Override public void setActionBytes(byte[] actionBytes){
  this.actionBytes=new ByteArrayRange(actionBytes);
}
Program: 61675
Project: 61675
Buggy source:
/** 
 * Gets data bytes
 * @return Bytes of data
 */
@Override public byte[] getData(){
  ByteArrayOutputStream baos=new ByteArrayOutputStream();
  OutputStream os=baos;
  if (Configuration.debugCopy.get()) {
    os=new CopyOutputStream(os,new ByteArrayInputStream(getOriginalData()));
  }
  SWFOutputStream sos=new SWFOutputStream(os,getVersion());
  try {
    sos.writeUI16(buttonId);
    sos.writeBUTTONRECORDList(characters,false);
    sos.write(actionBytes);
    sos.close();
  }
 catch (  IOException e) {
  }
  return baos.toByteArray();
}

Fixed version (ground truth):
/** 
 * Gets data bytes
 * @return Bytes of data
 */
@Override public byte[] getData(){
  ByteArrayOutputStream baos=new ByteArrayOutputStream();
  OutputStream os=baos;
  if (Configuration.debugCopy.get()) {
    os=new CopyOutputStream(os,new ByteArrayInputStream(getOriginalData()));
  }
  SWFOutputStream sos=new SWFOutputStream(os,getVersion());
  try {
    sos.writeUI16(buttonId);
    sos.writeBUTTONRECORDList(characters,false);
    sos.write(getActionBytes());
    sos.close();
  }
 catch (  IOException e) {
  }
  return baos.toByteArray();
}
Program: 61676
Project: 61676
Buggy source:
@Override public byte[] getActionBytes(){
  return actionBytes;
}

Fixed version (ground truth):
@Override public byte[] getActionBytes(){
  return actionBytes.getRangeData();
}
Program: 61677
Project: 61677
Buggy source:
/** 
 * Constructor
 * @param swf
 * @param data
 */
public DoActionTag(SWF swf,ByteArrayRange data){
  super(swf,ID,"String_Node_Str",data);
  actionBytes=new byte[0];
}

Fixed version (ground truth):
/** 
 * Constructor
 * @param swf
 * @param data
 */
public DoActionTag(SWF swf,ByteArrayRange data){
  super(swf,ID,"String_Node_Str",data);
  actionBytes=new ByteArrayRange(new byte[0]);
}
Program: 61678
Project: 61678
Buggy source:
@Override public void setActions(List<Action> actions){
  actionBytes=Action.actionsToBytes(actions,true,swf.version);
}

Fixed version (ground truth):
@Override public void setActions(List<Action> actions){
  byte[] bytes=Action.actionsToBytes(actions,true,swf.version);
  actionBytes=new ByteArrayRange(bytes,0,bytes.length);
}
Program: 61679
Project: 61679
Buggy source:
@Override public GraphTextWriter getActionBytesAsHex(GraphTextWriter writer){
  return Helper.byteArrayToHexWithHeader(writer,actionBytes);
}

Fixed version (ground truth):
@Override public GraphTextWriter getActionBytesAsHex(GraphTextWriter writer){
  return Helper.byteArrayToHexWithHeader(writer,actionBytes.getRangeData());
}
Program: 61680
Project: 61680
Buggy source:
@Override public List<Action> getActions() throws InterruptedException {
  try {
    int prevLength;
    SWFInputStream rri;
    if (actionBytes == null) {
      prevLength=(int)getDataPos();
      rri=new SWFInputStream(swf,getOriginalRange().array);
      rri.seek(prevLength);
    }
 else {
      prevLength=0;
      rri=new SWFInputStream(swf,actionBytes);
    }
    List<Action> list=ActionListReader.readActionListTimeout(listeners,rri,getVersion(),prevLength,-1,toString());
    return list;
  }
 catch (  InterruptedException ex) {
    throw ex;
  }
catch (  Exception ex) {
    Logger.getLogger(DoActionTag.class.getName()).log(Level.SEVERE,null,ex);
    return new ArrayList<>();
  }
}

Fixed version (ground truth):
@Override public List<Action> getActions() throws InterruptedException {
  try {
    int prevLength=actionBytes.pos;
    SWFInputStream rri=new SWFInputStream(swf,actionBytes.array);
    if (prevLength != 0) {
      rri.seek(prevLength);
    }
    List<Action> list=ActionListReader.readActionListTimeout(listeners,rri,getVersion(),prevLength,-1,toString());
    return list;
  }
 catch (  InterruptedException ex) {
    throw ex;
  }
catch (  Exception ex) {
    Logger.getLogger(DoActionTag.class.getName()).log(Level.SEVERE,null,ex);
    return new ArrayList<>();
  }
}
Program: 61681
Project: 61681
Buggy source:
@Override public void setActionBytes(byte[] actionBytes){
  this.actionBytes=actionBytes;
}

Fixed version (ground truth):
@Override public void setActionBytes(byte[] actionBytes){
  this.actionBytes=new ByteArrayRange(actionBytes);
}
Program: 61682
Project: 61682
Buggy source:
@Override public byte[] getActionBytes(){
  return actionBytes;
}

Fixed version (ground truth):
@Override public byte[] getActionBytes(){
  return actionBytes.getRangeData();
}
Program: 61683
Project: 61683
Buggy source:
/** 
 * Gets data bytes
 * @return Bytes of data
 */
@Override public byte[] getData(){
  return actionBytes;
}

Fixed version (ground truth):
/** 
 * Gets data bytes
 * @return Bytes of data
 */
@Override public byte[] getData(){
  return getActionBytes();
}
Program: 61684
Project: 61684
Buggy source:
@Override public void setActions(List<Action> actions){
  actionBytes=Action.actionsToBytes(actions,true,swf.version);
}

Fixed version (ground truth):
@Override public void setActions(List<Action> actions){
  byte[] bytes=Action.actionsToBytes(actions,true,swf.version);
  actionBytes=new ByteArrayRange(bytes,0,bytes.length);
}
Program: 61685
Project: 61685
Buggy source:
@Override public GraphTextWriter getActionBytesAsHex(GraphTextWriter writer){
  return Helper.byteArrayToHexWithHeader(writer,actionBytes);
}

Fixed version (ground truth):
@Override public GraphTextWriter getActionBytesAsHex(GraphTextWriter writer){
  return Helper.byteArrayToHexWithHeader(writer,actionBytes.getRangeData());
}
Program: 61686
Project: 61686
Buggy source:
@Override public List<Action> getActions() throws InterruptedException {
  try {
    int prevLength;
    SWFInputStream rri;
    if (actionBytes == null) {
      prevLength=(int)(getDataPos() + 2);
      rri=new SWFInputStream(swf,getOriginalRange().array);
      rri.seek(prevLength);
    }
 else {
      prevLength=0;
      rri=new SWFInputStream(swf,actionBytes);
    }
    List<Action> list=ActionListReader.readActionListTimeout(listeners,rri,getVersion(),prevLength,-1,toString());
    return list;
  }
 catch (  InterruptedException ex) {
    throw ex;
  }
catch (  Exception ex) {
    Logger.getLogger(DoActionTag.class.getName()).log(Level.SEVERE,null,ex);
    return new ArrayList<>();
  }
}

Fixed version (ground truth):
@Override public List<Action> getActions() throws InterruptedException {
  try {
    int prevLength=actionBytes.pos;
    SWFInputStream rri=new SWFInputStream(swf,actionBytes.array);
    if (prevLength != 0) {
      rri.seek(prevLength);
    }
    List<Action> list=ActionListReader.readActionListTimeout(listeners,rri,getVersion(),prevLength,-1,toString());
    return list;
  }
 catch (  InterruptedException ex) {
    throw ex;
  }
catch (  Exception ex) {
    Logger.getLogger(DoActionTag.class.getName()).log(Level.SEVERE,null,ex);
    return new ArrayList<>();
  }
}
Program: 61687
Project: 61687
Buggy source:
/** 
 * Constructor
 * @param sis
 * @param data
 * @throws IOException
 */
public DoInitActionTag(SWFInputStream sis,ByteArrayRange data) throws IOException {
  super(sis.getSwf(),ID,"String_Node_Str",data);
  spriteId=sis.readUI16("String_Node_Str");
  sis.readBytesEx(sis.available(),"String_Node_Str");
}

Fixed version (ground truth):
/** 
 * Constructor
 * @param sis
 * @param data
 * @throws IOException
 */
public DoInitActionTag(SWFInputStream sis,ByteArrayRange data) throws IOException {
  super(sis.getSwf(),ID,"String_Node_Str",data);
  spriteId=sis.readUI16("String_Node_Str");
  int pos=(int)sis.getPos();
  byte[] bytes=sis.readBytesEx(sis.available(),"String_Node_Str");
  actionBytes=new ByteArrayRange(data.array,pos,bytes.length);
}
Program: 61688
Project: 61688
Buggy source:
@Override public void setActionBytes(byte[] actionBytes){
  this.actionBytes=actionBytes;
}

Fixed version (ground truth):
@Override public void setActionBytes(byte[] actionBytes){
  this.actionBytes=new ByteArrayRange(actionBytes);
}
Program: 61689
Project: 61689
Buggy source:
@Override public byte[] getActionBytes(){
  return actionBytes;
}

Fixed version (ground truth):
@Override public byte[] getActionBytes(){
  return actionBytes.getRangeData();
}
Program: 61690
Project: 61690
Buggy source:
/** 
 * Gets data bytes
 * @return Bytes of data
 */
@Override public byte[] getData(){
  ByteArrayOutputStream baos=new ByteArrayOutputStream();
  SWFOutputStream sos=new SWFOutputStream(baos,getVersion());
  try {
    sos.writeUI16(spriteId);
    sos.write(actionBytes);
    sos.close();
  }
 catch (  IOException e) {
  }
  return baos.toByteArray();
}

Fixed version (ground truth):
/** 
 * Gets data bytes
 * @return Bytes of data
 */
@Override public byte[] getData(){
  ByteArrayOutputStream baos=new ByteArrayOutputStream();
  SWFOutputStream sos=new SWFOutputStream(baos,getVersion());
  try {
    sos.writeUI16(spriteId);
    sos.write(getActionBytes());
    sos.close();
  }
 catch (  IOException e) {
  }
  return baos.toByteArray();
}
Program: 61691
Project: 61691
Buggy source:
public void clearModified(){
  for (  Tag tag : tags) {
    if (tag.isModified()) {
      tag.setModified(false);
    }
  }
  ByteArrayOutputStream baos=new ByteArrayOutputStream();
  try {
    saveTo(baos,SWFCompression.NONE);
    byte[] swfData=baos.toByteArray();
    uncompressedData=swfData;
  }
 catch (  IOException ex) {
    Logger.getLogger(SWF.class.getName()).log(Level.SEVERE,"String_Node_Str",ex);
  }
}

Fixed version (ground truth):
public void clearModified(){
  for (  Tag tag : tags) {
    if (tag.isModified()) {
      tag.createOriginalData();
      tag.setModified(false);
    }
  }
  ByteArrayOutputStream baos=new ByteArrayOutputStream();
  try {
    saveTo(baos,SWFCompression.NONE);
    byte[] swfData=baos.toByteArray();
    uncompressedData=swfData;
  }
 catch (  IOException ex) {
    Logger.getLogger(SWF.class.getName()).log(Level.SEVERE,"String_Node_Str",ex);
  }
}
Program: 61693
Project: 61693
Buggy source:
@Test public void testFIXEDandFIXED8() throws IOException {
  byte[] data=new byte[]{(byte)0x00,(byte)0x80,(byte)0x07,(byte)0x00};
  SWFInputStream sis=new SWFInputStream(null,data);
  assertTrue(Double.compare(7.5,sis.readFIXED()) == 0);
  sis.close();
  ByteArrayOutputStream baos=new ByteArrayOutputStream();
  SWFOutputStream sos=new SWFOutputStream(baos,SWF.DEFAULT_VERSION);
  double dd=5.25;
  sos.writeFIXED(dd);
  sos.close();
  sis=new SWFInputStream(null,baos.toByteArray());
  assertTrue(Double.compare(dd,sis.readFIXED()) == 0);
  sis.close();
  baos=new ByteArrayOutputStream();
  sos=new SWFOutputStream(baos,SWF.DEFAULT_VERSION);
  float ff=5.25f;
  sos.writeFIXED8(ff);
  sos.close();
  sis=new SWFInputStream(null,baos.toByteArray());
  assertEquals(ff,sis.readFIXED8());
  sis.close();
}

Fixed version (ground truth):
@Test public void testFIXEDandFIXED8() throws IOException {
  byte[] data=new byte[]{(byte)0x00,(byte)0x80,(byte)0x07,(byte)0x00};
  SWFInputStream sis=new SWFInputStream(null,data);
  assertTrue(Double.compare(7.5,sis.readFIXED("String_Node_Str")) == 0);
  sis.close();
  ByteArrayOutputStream baos=new ByteArrayOutputStream();
  SWFOutputStream sos=new SWFOutputStream(baos,SWF.DEFAULT_VERSION);
  double dd=5.25;
  sos.writeFIXED(dd);
  sos.close();
  sis=new SWFInputStream(null,baos.toByteArray());
  assertTrue(Double.compare(dd,sis.readFIXED("String_Node_Str")) == 0);
  sis.close();
  baos=new ByteArrayOutputStream();
  sos=new SWFOutputStream(baos,SWF.DEFAULT_VERSION);
  float ff=5.25f;
  sos.writeFIXED8(ff);
  sos.close();
  sis=new SWFInputStream(null,baos.toByteArray());
  assertEquals(ff,sis.readFIXED8("String_Node_Str"));
  sis.close();
}
Program: 61694
Project: 61694
Buggy source:
@Test public void testRECT() throws IOException {
  RECT rect;
  ByteArrayOutputStream baos=new ByteArrayOutputStream();
  try (SWFOutputStream sos=new SWFOutputStream(baos,SWF.DEFAULT_VERSION)){
    rect=new RECT(-0x80000000,0x7FFFFFFF,-0x80000000,0x7FFFFFFF);
    sos.writeRECT(rect);
  }
   try (SWFInputStream sis=new SWFInputStream(null,baos.toByteArray())){
    RECT readRECT=sis.readRECT();
    assertEquals(readRECT.Xmin,-0x3FFFFFFF);
    assertEquals(readRECT.Xmax,0x3FFFFFFF);
    assertEquals(readRECT.Ymin,-0x3FFFFFFF);
    assertEquals(readRECT.Ymax,0x3FFFFFFF);
  }
 }

Fixed version (ground truth):
@Test public void testRECT() throws IOException {
  RECT rect;
  ByteArrayOutputStream baos=new ByteArrayOutputStream();
  try (SWFOutputStream sos=new SWFOutputStream(baos,SWF.DEFAULT_VERSION)){
    rect=new RECT(-0x80000000,0x7FFFFFFF,-0x80000000,0x7FFFFFFF);
    sos.writeRECT(rect);
  }
   try (SWFInputStream sis=new SWFInputStream(null,baos.toByteArray())){
    RECT readRECT=sis.readRECT("String_Node_Str");
    assertEquals(readRECT.Xmin,-0x3FFFFFFF);
    assertEquals(readRECT.Xmax,0x3FFFFFFF);
    assertEquals(readRECT.Ymin,-0x3FFFFFFF);
    assertEquals(readRECT.Ymax,0x3FFFFFFF);
  }
 }
Program: 61695
Project: 61695
Buggy source:
@Test public void testSB() throws IOException {
  ByteArrayOutputStream baos=new ByteArrayOutputStream();
  try (SWFOutputStream sos=new SWFOutputStream(baos,SWF.DEFAULT_VERSION)){
    sos.writeSB(5,-1);
    sos.writeSB(6,2);
    sos.writeSB(7,-3);
    sos.writeSB(8,4);
    sos.writeSB(9,-5);
  }
   try (SWFInputStream sis=new SWFInputStream(null,baos.toByteArray())){
    assertEquals(-1,sis.readSB(5));
    assertEquals(2,sis.readSB(6));
    assertEquals(-3,sis.readSB(7));
    assertEquals(4,sis.readSB(8));
    assertEquals(-5,sis.readSB(9));
  }
 }

Fixed version (ground truth):
@Test public void testSB() throws IOException {
  ByteArrayOutputStream baos=new ByteArrayOutputStream();
  try (SWFOutputStream sos=new SWFOutputStream(baos,SWF.DEFAULT_VERSION)){
    sos.writeSB(5,-1);
    sos.writeSB(6,2);
    sos.writeSB(7,-3);
    sos.writeSB(8,4);
    sos.writeSB(9,-5);
  }
   try (SWFInputStream sis=new SWFInputStream(null,baos.toByteArray())){
    assertEquals(-1,sis.readSB(5,"String_Node_Str"));
    assertEquals(2,sis.readSB(6,"String_Node_Str"));
    assertEquals(-3,sis.readSB(7,"String_Node_Str"));
    assertEquals(4,sis.readSB(8,"String_Node_Str"));
    assertEquals(-5,sis.readSB(9,"String_Node_Str"));
  }
 }
Program: 61696
Project: 61696
Buggy source:
@Test public void testUB() throws IOException {
  ByteArrayOutputStream baos=new ByteArrayOutputStream();
  try (SWFOutputStream sos=new SWFOutputStream(baos,SWF.DEFAULT_VERSION)){
    sos.writeUB(5,1);
    sos.writeUB(6,2);
    sos.writeUB(7,3);
    sos.writeUB(8,4);
    sos.writeUB(9,5);
  }
   try (SWFInputStream sis=new SWFInputStream(null,baos.toByteArray())){
    assertEquals(1,sis.readUB(5));
    assertEquals(2,sis.readUB(6));
    assertEquals(3,sis.readUB(7));
    assertEquals(4,sis.readUB(8));
    assertEquals(5,sis.readUB(9));
  }
 }

Fixed version (ground truth):
@Test public void testUB() throws IOException {
  ByteArrayOutputStream baos=new ByteArrayOutputStream();
  try (SWFOutputStream sos=new SWFOutputStream(baos,SWF.DEFAULT_VERSION)){
    sos.writeUB(5,1);
    sos.writeUB(6,2);
    sos.writeUB(7,3);
    sos.writeUB(8,4);
    sos.writeUB(9,5);
  }
   try (SWFInputStream sis=new SWFInputStream(null,baos.toByteArray())){
    assertEquals(1,sis.readUB(5,"String_Node_Str"));
    assertEquals(2,sis.readUB(6,"String_Node_Str"));
    assertEquals(3,sis.readUB(7,"String_Node_Str"));
    assertEquals(4,sis.readUB(8,"String_Node_Str"));
    assertEquals(5,sis.readUB(9,"String_Node_Str"));
  }
 }
Program: 61697
Project: 61697
Buggy source:
@Test public void testFLOATAndDouble() throws IOException {
  ByteArrayOutputStream baos=new ByteArrayOutputStream();
  SWFOutputStream sos=new SWFOutputStream(baos,SWF.DEFAULT_VERSION);
  float f=5.25f;
  sos.writeFLOAT(f);
  sos.close();
  SWFInputStream sis=new SWFInputStream(null,baos.toByteArray());
  assertEquals(f,sis.readFLOAT());
  sis.close();
  baos=new ByteArrayOutputStream();
  sos=new SWFOutputStream(baos,SWF.DEFAULT_VERSION);
  f=5.25f;
  sos.writeFLOAT16(f);
  sos.close();
  sis=new SWFInputStream(null,baos.toByteArray());
  assertEquals(f,sis.readFLOAT16());
  sis.close();
  baos=new ByteArrayOutputStream();
  sos=new SWFOutputStream(baos,SWF.DEFAULT_VERSION);
  double d=5.25;
  sos.writeDOUBLE(d);
  sos.close();
  sis=new SWFInputStream(null,baos.toByteArray());
  assertEquals(d,sis.readDOUBLE());
  sis.close();
}

Fixed version (ground truth):
@Test public void testFLOATAndDouble() throws IOException {
  ByteArrayOutputStream baos=new ByteArrayOutputStream();
  SWFOutputStream sos=new SWFOutputStream(baos,SWF.DEFAULT_VERSION);
  float f=5.25f;
  sos.writeFLOAT(f);
  sos.close();
  SWFInputStream sis=new SWFInputStream(null,baos.toByteArray());
  assertEquals(f,sis.readFLOAT("String_Node_Str"));
  sis.close();
  baos=new ByteArrayOutputStream();
  sos=new SWFOutputStream(baos,SWF.DEFAULT_VERSION);
  f=5.25f;
  sos.writeFLOAT16(f);
  sos.close();
  sis=new SWFInputStream(null,baos.toByteArray());
  assertEquals(f,sis.readFLOAT16("String_Node_Str"));
  sis.close();
  baos=new ByteArrayOutputStream();
  sos=new SWFOutputStream(baos,SWF.DEFAULT_VERSION);
  double d=5.25;
  sos.writeDOUBLE(d);
  sos.close();
  sis=new SWFInputStream(null,baos.toByteArray());
  assertEquals(d,sis.readDOUBLE("String_Node_Str"));
  sis.close();
}
Program: 61698
Project: 61698
Buggy source:
@Test public void testFB() throws IOException {
  double f=5.25;
  ByteArrayOutputStream baos=new ByteArrayOutputStream();
  try (SWFOutputStream sos=new SWFOutputStream(baos,SWF.DEFAULT_VERSION)){
    sos.writeFB(20,f);
  }
   try (SWFInputStream sis=new SWFInputStream(null,baos.toByteArray())){
    assertTrue(Double.compare(f,sis.readFB(20)) == 0);
  }
 }

Fixed version (ground truth):
@Test public void testFB() throws IOException {
  double f=5.25;
  ByteArrayOutputStream baos=new ByteArrayOutputStream();
  try (SWFOutputStream sos=new SWFOutputStream(baos,SWF.DEFAULT_VERSION)){
    sos.writeFB(20,f);
  }
   try (SWFInputStream sis=new SWFInputStream(null,baos.toByteArray())){
    assertTrue(Double.compare(f,sis.readFB(20,"String_Node_Str")) == 0);
  }
 }
Program: 61700
Project: 61700
Buggy source:
@Override public GraphTextWriter appendTo(GraphTextWriter writer,LocalData localData) throws InterruptedException {
  boolean singleLine=pairs.size() < 2;
  if (!singleLine) {
    writer.newLine();
    writer.indent();
  }
  writer.append("String_Node_Str");
  if (!singleLine) {
    writer.newLine();
    writer.indent();
  }
  for (int n=0; n < pairs.size(); n++) {
    if (n > 0) {
      writer.append("String_Node_Str").newLine();
    }
    pairs.get(n).toString(writer,localData);
  }
  if (!singleLine) {
    writer.newLine();
    writer.unindent();
  }
  writer.append("String_Node_Str");
  if (!singleLine) {
    writer.unindent();
  }
  return writer;
}

Fixed version (ground truth):
@Override public GraphTextWriter appendTo(GraphTextWriter writer,LocalData localData) throws InterruptedException {
  boolean singleLine=pairs.size() < 2;
  writer.append("String_Node_Str");
  if (!singleLine) {
    writer.newLine();
    writer.indent();
  }
  for (int n=0; n < pairs.size(); n++) {
    if (n > 0) {
      writer.append("String_Node_Str").newLine();
    }
    pairs.get(n).toString(writer,localData);
  }
  if (!singleLine) {
    writer.newLine();
    writer.unindent();
  }
  writer.append("String_Node_Str");
  return writer;
}