Program: 58431
Project: 58431
Buggy source:
private static byte[] writeWorld(String name,String transformedName,byte[] bytes,ClassReader cr){
  String[] names;
  if (LoadingPlugin.runtimeDeobfEnabled) {
    names=new String[]{"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"};
  }
 else {
    names=new String[]{"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"};
  }
  name=name.replace('.','/');
  ClassNode cn=new ClassNode(ASM4);
  cr.accept(cn,ClassReader.EXPAND_FRAMES);
  final String sig="String_Node_Str";
  FMLDeobfuscatingRemapper remapper=FMLDeobfuscatingRemapper.INSTANCE;
  MethodNode addTileEntity=null, addTileEntities=null, setTileEntity=null, updateEntities=null;
  boolean found=false;
  for (  MethodNode m : cn.methods) {
    if ("String_Node_Str".equals(m.name)) {
      if (sig.equals(remapper.mapMethodDesc(m.desc)))       found=true;
      LabelNode a=new LabelNode(new Label());
      AbstractInsnNode n=m.instructions.getLast();
      while (n.getOpcode() != RETURN)       n=n.getPrevious();
      m.instructions.insertBefore(n,a);
      m.instructions.insertBefore(n,new LineNumberNode(-15000,a));
      m.instructions.insertBefore(n,new VarInsnNode(ALOAD,0));
      m.instructions.insertBefore(n,new TypeInsnNode(NEW,"String_Node_Str"));
      m.instructions.insertBefore(n,new InsnNode(DUP));
      m.instructions.insertBefore(n,new MethodInsnNode(INVOKESPECIAL,"String_Node_Str","String_Node_Str","String_Node_Str",false));
      m.instructions.insertBefore(n,new FieldInsnNode(PUTFIELD,"String_Node_Str","String_Node_Str","String_Node_Str"));
    }
 else     if ("String_Node_Str".equals(m.name) && "String_Node_Str".equals(remapper.mapMethodDesc(m.desc))) {
      addTileEntity=m;
    }
 else     if (names[4].equals(remapper.mapMethodName(name,m.name,m.desc)) && "String_Node_Str".equals(m.desc)) {
      addTileEntities=m;
    }
 else     if (names[5].equals(remapper.mapMethodName(name,m.name,m.desc)) && "String_Node_Str".equals(remapper.mapMethodDesc(m.desc))) {
      setTileEntity=m;
    }
 else     if (names[6].equals(remapper.mapMethodName(name,m.name,m.desc)) && "String_Node_Str".equals(remapper.mapMethodDesc(m.desc))) {
      updateEntities=m;
    }
  }
  cn.fields.add(new FieldNode(ACC_PRIVATE,"String_Node_Str","String_Node_Str",null,null));
  if (addTileEntity != null) {
    LabelNode a=new LabelNode(new Label());
    AbstractInsnNode n;
    addTileEntity.instructions.insert(n=a);
    addTileEntity.instructions.insert(n,n=new LineNumberNode(-15001,a));
    addTileEntity.instructions.insert(n,n=new VarInsnNode(ALOAD,0));
    addTileEntity.instructions.insert(n,n=new FieldInsnNode(GETFIELD,"String_Node_Str","String_Node_Str","String_Node_Str"));
    addTileEntity.instructions.insert(n,n=new VarInsnNode(ALOAD,1));
    addTileEntity.instructions.insert(n,n=new MethodInsnNode(INVOKEVIRTUAL,"String_Node_Str","String_Node_Str","String_Node_Str",false));
    addTileEntity.instructions.insert(n,n=new InsnNode(POP));
  }
  if (setTileEntity != null) {
    LabelNode a=new LabelNode(new Label());
    AbstractInsnNode n=setTileEntity.instructions.getLast();
    while (n.getOpcode() != RETURN)     n=n.getPrevious();
    n=n.getPrevious();
    setTileEntity.instructions.insert(n=a);
    setTileEntity.instructions.insert(n,n=new LineNumberNode(-15002,a));
    setTileEntity.instructions.insert(n,n=new VarInsnNode(ALOAD,0));
    setTileEntity.instructions.insert(n,n=new FieldInsnNode(GETFIELD,"String_Node_Str","String_Node_Str","String_Node_Str"));
    setTileEntity.instructions.insert(n,n=new VarInsnNode(ALOAD,4));
    setTileEntity.instructions.insert(n,n=new MethodInsnNode(INVOKEVIRTUAL,"String_Node_Str","String_Node_Str","String_Node_Str",false));
    setTileEntity.instructions.insert(n,n=new InsnNode(POP));
  }
  if (addTileEntities != null) {
    LabelNode a=new LabelNode(new Label());
    AbstractInsnNode n=addTileEntities.instructions.getFirst();
    while (n.getOpcode() != CHECKCAST)     n=n.getNext();
    n=n.getNext();
    VarInsnNode store=(VarInsnNode)n;
    addTileEntities.instructions.insert(n,n=a);
    addTileEntities.instructions.insert(n,n=new LineNumberNode(-15003,a));
    addTileEntities.instructions.insert(n,n=new VarInsnNode(ALOAD,0));
    addTileEntities.instructions.insert(n,n=new FieldInsnNode(GETFIELD,"String_Node_Str","String_Node_Str","String_Node_Str"));
    addTileEntities.instructions.insert(n,n=new VarInsnNode(ALOAD,store.var));
    addTileEntities.instructions.insert(n,n=new MethodInsnNode(INVOKEVIRTUAL,"String_Node_Str","String_Node_Str","String_Node_Str",false));
    addTileEntities.instructions.insert(n,n=new InsnNode(POP));
  }
  if (updateEntities != null) {
    AbstractInsnNode n=updateEntities.instructions.getFirst();
    while (n.getOpcode() != INVOKEVIRTUAL || !"String_Node_Str".equals(((MethodInsnNode)n).name) || !"String_Node_Str".equals(((MethodInsnNode)n).desc))     n=n.getNext();
    while (n.getOpcode() != PUTFIELD)     n=n.getNext();
    n=n.getPrevious().getPrevious();
    LabelNode lStart=new LabelNode(new Label());
    LabelNode lCond=new LabelNode(new Label());
    LabelNode a=new LabelNode(new Label());
    updateEntities.instructions.insert(n,n=a);
    updateEntities.instructions.insert(n,n=new LineNumberNode(-15004,a));
    updateEntities.instructions.insert(n,n=new JumpInsnNode(GOTO,lCond));
    updateEntities.instructions.insert(n,n=lStart);
    updateEntities.instructions.insert(n,n=new FrameNode(F_SAME,0,null,0,null));
    updateEntities.instructions.insert(n,n=new VarInsnNode(ALOAD,0));
    updateEntities.instructions.insert(n,n=new FieldInsnNode(GETFIELD,"String_Node_Str","String_Node_Str","String_Node_Str"));
    updateEntities.instructions.insert(n,n=new MethodInsnNode(INVOKEVIRTUAL,"String_Node_Str","String_Node_Str","String_Node_Str",false));
    updateEntities.instructions.insert(n,n=new TypeInsnNode(CHECKCAST,"String_Node_Str"));
    updateEntities.instructions.insert(n,n=new MethodInsnNode(INVOKEVIRTUAL,"String_Node_Str","String_Node_Str","String_Node_Str",false));
    updateEntities.instructions.insert(n,n=lCond);
    updateEntities.instructions.insert(n,n=new FrameNode(F_SAME,0,null,0,null));
    updateEntities.instructions.insert(n,n=new VarInsnNode(ALOAD,0));
    updateEntities.instructions.insert(n,n=new FieldInsnNode(GETFIELD,"String_Node_Str","String_Node_Str","String_Node_Str"));
    updateEntities.instructions.insert(n,n=new MethodInsnNode(INVOKEVIRTUAL,"String_Node_Str","String_Node_Str","String_Node_Str",false));
    updateEntities.instructions.insert(n,n=new JumpInsnNode(IFNE,lStart));
  }
  ClassWriter cw=new ClassWriter(ClassWriter.COMPUTE_FRAMES);
  cn.accept(cw);
  if (!found) {
    cw.newMethod(name,"String_Node_Str",sig,true);
    MethodVisitor mv=cw.visitMethod(ACC_PUBLIC,"String_Node_Str",sig,null,null);
    mv.visitCode();
    mv.visitVarInsn(ALOAD,0);
    mv.visitInsn(DUP);
    mv.visitInsn(DUP);
    mv.visitInsn(DUP);
    mv.visitInsn(DUP);
    mv.visitInsn(DUP);
    mv.visitMethodInsn(INVOKESPECIAL,"String_Node_Str","String_Node_Str","String_Node_Str",false);
    mv.visitVarInsn(ALOAD,1);
    mv.visitFieldInsn(PUTFIELD,name,names[0],"String_Node_Str");
    mv.visitTypeInsn(NEW,"String_Node_Str");
    mv.visitInsn(DUP);
    mv.visitVarInsn(ALOAD,4);
    mv.visitVarInsn(ALOAD,2);
    mv.visitMethodInsn(INVOKESPECIAL,"String_Node_Str","String_Node_Str","String_Node_Str",false);
    mv.visitFieldInsn(PUTFIELD,name,names[1],"String_Node_Str");
    mv.visitVarInsn(ALOAD,3);
    mv.visitFieldInsn(PUTFIELD,name,names[2],"String_Node_Str");
    mv.visitVarInsn(ALOAD,5);
    mv.visitFieldInsn(PUTFIELD,name,names[3],"String_Node_Str");
    mv.visitInsn(RETURN);
    mv.visitMaxs(11,10);
    mv.visitEnd();
    cw.visitEnd();
  }
  bytes=cw.toByteArray();
  return bytes;
}

Fixed version (ground truth):
private static byte[] writeWorld(String name,String transformedName,byte[] bytes,ClassReader cr){
  String[] names;
  if (LoadingPlugin.runtimeDeobfEnabled) {
    names=new String[]{"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"};
  }
 else {
    names=new String[]{"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"};
  }
  name=name.replace('.','/');
  ClassNode cn=new ClassNode(ASM4);
  cr.accept(cn,ClassReader.EXPAND_FRAMES);
  final String sig="String_Node_Str";
  FMLDeobfuscatingRemapper remapper=FMLDeobfuscatingRemapper.INSTANCE;
  MethodNode addTileEntity=null, addTileEntities=null, setTileEntity=null, updateEntities=null;
  boolean found=false;
  for (  MethodNode m : cn.methods) {
    if ("String_Node_Str".equals(m.name)) {
      if (sig.equals(remapper.mapMethodDesc(m.desc)))       found=true;
      LabelNode a=new LabelNode(new Label());
      AbstractInsnNode n=m.instructions.getLast();
      while (n.getOpcode() != RETURN)       n=n.getPrevious();
      m.instructions.insertBefore(n,a);
      m.instructions.insertBefore(n,new LineNumberNode(-15000,a));
      m.instructions.insertBefore(n,new VarInsnNode(ALOAD,0));
      m.instructions.insertBefore(n,new TypeInsnNode(NEW,"String_Node_Str"));
      m.instructions.insertBefore(n,new InsnNode(DUP));
      m.instructions.insertBefore(n,new MethodInsnNode(INVOKESPECIAL,"String_Node_Str","String_Node_Str","String_Node_Str",false));
      m.instructions.insertBefore(n,new FieldInsnNode(PUTFIELD,"String_Node_Str","String_Node_Str","String_Node_Str"));
    }
 else     if ("String_Node_Str".equals(m.name) && "String_Node_Str".equals(remapper.mapMethodDesc(m.desc))) {
      addTileEntity=m;
    }
 else     if (names[4].equals(remapper.mapMethodName(name,m.name,m.desc)) && "String_Node_Str".equals(m.desc)) {
      addTileEntities=m;
    }
 else     if (names[5].equals(remapper.mapMethodName(name,m.name,m.desc)) && "String_Node_Str".equals(remapper.mapMethodDesc(m.desc))) {
      setTileEntity=m;
    }
 else     if (names[6].equals(remapper.mapMethodName(name,m.name,m.desc)) && "String_Node_Str".equals(remapper.mapMethodDesc(m.desc))) {
      updateEntities=m;
    }
  }
  cn.fields.add(new FieldNode(ACC_PRIVATE,"String_Node_Str","String_Node_Str",null,null));
  if (addTileEntity != null) {
    LabelNode a=new LabelNode(new Label());
    AbstractInsnNode n;
    addTileEntity.instructions.insert(n=a);
    addTileEntity.instructions.insert(n,n=new LineNumberNode(-15001,a));
    addTileEntity.instructions.insert(n,n=new VarInsnNode(ALOAD,0));
    addTileEntity.instructions.insert(n,n=new FieldInsnNode(GETFIELD,"String_Node_Str","String_Node_Str","String_Node_Str"));
    addTileEntity.instructions.insert(n,n=new VarInsnNode(ALOAD,1));
    addTileEntity.instructions.insert(n,n=new MethodInsnNode(INVOKEVIRTUAL,"String_Node_Str","String_Node_Str","String_Node_Str",false));
    addTileEntity.instructions.insert(n,n=new InsnNode(POP));
  }
  if (setTileEntity != null) {
    LabelNode a=new LabelNode(new Label());
    AbstractInsnNode n=setTileEntity.instructions.getLast();
    while (n.getOpcode() != RETURN)     n=n.getPrevious();
    n=n.getPrevious();
    setTileEntity.instructions.insert(n=a);
    setTileEntity.instructions.insert(n,n=new LineNumberNode(-15002,a));
    setTileEntity.instructions.insert(n,n=new VarInsnNode(ALOAD,0));
    setTileEntity.instructions.insert(n,n=new FieldInsnNode(GETFIELD,"String_Node_Str","String_Node_Str","String_Node_Str"));
    setTileEntity.instructions.insert(n,n=new VarInsnNode(ALOAD,4));
    setTileEntity.instructions.insert(n,n=new MethodInsnNode(INVOKEVIRTUAL,"String_Node_Str","String_Node_Str","String_Node_Str",false));
    setTileEntity.instructions.insert(n,n=new InsnNode(POP));
  }
  if (addTileEntities != null) {
    LabelNode a=new LabelNode(new Label());
    AbstractInsnNode n=addTileEntities.instructions.getFirst();
    while (n.getOpcode() != CHECKCAST)     n=n.getNext();
    n=n.getNext();
    VarInsnNode store=(VarInsnNode)n;
    addTileEntities.instructions.insert(n,n=a);
    addTileEntities.instructions.insert(n,n=new LineNumberNode(-15003,a));
    addTileEntities.instructions.insert(n,n=new VarInsnNode(ALOAD,0));
    addTileEntities.instructions.insert(n,n=new FieldInsnNode(GETFIELD,"String_Node_Str","String_Node_Str","String_Node_Str"));
    addTileEntities.instructions.insert(n,n=new VarInsnNode(ALOAD,store.var));
    addTileEntities.instructions.insert(n,n=new MethodInsnNode(INVOKEVIRTUAL,"String_Node_Str","String_Node_Str","String_Node_Str",false));
    addTileEntities.instructions.insert(n,n=new InsnNode(POP));
  }
  if (updateEntities != null) {
    AbstractInsnNode n=updateEntities.instructions.getFirst();
    while (n.getOpcode() != INVOKEVIRTUAL || !"String_Node_Str".equals(((MethodInsnNode)n).name) || !"String_Node_Str".equals(((MethodInsnNode)n).desc))     n=n.getNext();
    while (n.getOpcode() != PUTFIELD)     n=n.getNext();
    n=n.getPrevious().getPrevious();
    LabelNode lStart=new LabelNode(new Label());
    LabelNode lCond=new LabelNode(new Label());
    LabelNode lGuard=new LabelNode(new Label());
    LabelNode a=new LabelNode(new Label());
    updateEntities.instructions.insert(n,n=a);
    updateEntities.instructions.insert(n,n=new LineNumberNode(-15004,a));
    updateEntities.instructions.insert(n,n=new JumpInsnNode(GOTO,lCond));
    updateEntities.instructions.insert(n,n=lStart);
    updateEntities.instructions.insert(n,n=new FrameNode(F_SAME,0,null,0,null));
    updateEntities.instructions.insert(n,n=new VarInsnNode(ALOAD,0));
    updateEntities.instructions.insert(n,n=new FieldInsnNode(GETFIELD,"String_Node_Str","String_Node_Str","String_Node_Str"));
    updateEntities.instructions.insert(n,n=new MethodInsnNode(INVOKEVIRTUAL,"String_Node_Str","String_Node_Str","String_Node_Str",false));
    updateEntities.instructions.insert(n,n=new TypeInsnNode(CHECKCAST,"String_Node_Str"));
    updateEntities.instructions.insert(n,n=new InsnNode(DUP));
    updateEntities.instructions.insert(n,n=new JumpInsnNode(IFNULL,lGuard));
    updateEntities.instructions.insert(n,n=new MethodInsnNode(INVOKEVIRTUAL,"String_Node_Str","String_Node_Str","String_Node_Str",false));
    updateEntities.instructions.insert(n,n=new InsnNode(ACONST_NULL));
    updateEntities.instructions.insert(n,n=lGuard);
    updateEntities.instructions.insert(n,n=new InsnNode(POP));
    updateEntities.instructions.insert(n,n=lCond);
    updateEntities.instructions.insert(n,n=new FrameNode(F_SAME,0,null,0,null));
    updateEntities.instructions.insert(n,n=new VarInsnNode(ALOAD,0));
    updateEntities.instructions.insert(n,n=new FieldInsnNode(GETFIELD,"String_Node_Str","String_Node_Str","String_Node_Str"));
    updateEntities.instructions.insert(n,n=new MethodInsnNode(INVOKEVIRTUAL,"String_Node_Str","String_Node_Str","String_Node_Str",false));
    updateEntities.instructions.insert(n,n=new JumpInsnNode(IFNE,lStart));
  }
  ClassWriter cw=new ClassWriter(ClassWriter.COMPUTE_FRAMES);
  cn.accept(cw);
  if (!found) {
    cw.newMethod(name,"String_Node_Str",sig,true);
    MethodVisitor mv=cw.visitMethod(ACC_PUBLIC,"String_Node_Str",sig,null,null);
    mv.visitCode();
    mv.visitVarInsn(ALOAD,0);
    mv.visitInsn(DUP);
    mv.visitInsn(DUP);
    mv.visitInsn(DUP);
    mv.visitInsn(DUP);
    mv.visitInsn(DUP);
    mv.visitMethodInsn(INVOKESPECIAL,"String_Node_Str","String_Node_Str","String_Node_Str",false);
    mv.visitVarInsn(ALOAD,1);
    mv.visitFieldInsn(PUTFIELD,name,names[0],"String_Node_Str");
    mv.visitTypeInsn(NEW,"String_Node_Str");
    mv.visitInsn(DUP);
    mv.visitVarInsn(ALOAD,4);
    mv.visitVarInsn(ALOAD,2);
    mv.visitMethodInsn(INVOKESPECIAL,"String_Node_Str","String_Node_Str","String_Node_Str",false);
    mv.visitFieldInsn(PUTFIELD,name,names[1],"String_Node_Str");
    mv.visitVarInsn(ALOAD,3);
    mv.visitFieldInsn(PUTFIELD,name,names[2],"String_Node_Str");
    mv.visitVarInsn(ALOAD,5);
    mv.visitFieldInsn(PUTFIELD,name,names[3],"String_Node_Str");
    mv.visitInsn(RETURN);
    mv.visitMaxs(11,10);
    mv.visitEnd();
    cw.visitEnd();
  }
  bytes=cw.toByteArray();
  return bytes;
}