nus-yam/ex-repair huggingface dataset:
Program: 63120
Project: 63120
Buggy source:
public static short readNum(BinaryReader reader) throws IOException, SDKException {
  ScriptOp code=readOpCode(reader);
  if (code == ScriptOp.OP_PUSH0) {
    readOpCode(reader);
    return 0;
  }
 else {
    int num=(int)code.getByte() - (int)ScriptOp.OP_PUSH1.getByte() + 1;
    if (num >= 1 && num <= 16) {
      readOpCode(reader);
      return (short)num;
    }
  }
  byte[] buff=readBytes(reader);
  BigInteger bint=Helper.BigIntFromBytes(buff);
  long num=bint.longValue();
  if (num > Short.MAX_VALUE || num < 16) {
    throw new SDKException(ErrorCode.ParamErr("String_Node_Str"));
  }
  return (short)num;
}

Fixed version (ground truth):
public static short readNum(BinaryReader reader) throws IOException, SDKException {
  ScriptOp code=readOpCode(reader);
  if (code == ScriptOp.OP_PUSH0) {
    readOpCode(reader);
    return 0;
  }
 else {
    int num=(int)code.getByte() - (int)ScriptOp.OP_PUSH1.getByte() + 1;
    if (num >= 1 && num <= 16) {
      readOpCode(reader);
      return (short)num;
    }
  }
  byte[] buff=readBytes(reader);
  BigInteger bint=Helper.BigIntFromNeoBytes(buff);
  long num=bint.longValue();
  if (num > Short.MAX_VALUE || num < 16) {
    throw new SDKException(ErrorCode.ParamErr("String_Node_Str"));
  }
  return (short)num;
}
Program: 63121
Project: 63121
Buggy source:
public ScriptBuilder pushNum(short num){
  if (num == 0) {
    return add(ScriptOp.OP_PUSH0);
  }
 else   if (num < 16) {
    return add(ScriptOp.valueOf(num - 1 + ScriptOp.OP_PUSH1.getByte()));
  }
  BigInteger bint=BigInteger.valueOf(num);
  return push(Helper.BigInt2Bytes(bint));
}

Fixed version (ground truth):
public ScriptBuilder pushNum(short num){
  if (num == 0) {
    return add(ScriptOp.OP_PUSH0);
  }
 else   if (num < 16) {
    return add(ScriptOp.valueOf(num - 1 + ScriptOp.OP_PUSH1.getByte()));
  }
  BigInteger bint=BigInteger.valueOf(num);
  return push(Helper.BigIntToNeoBytes(bint));
}
Program: 63122
Project: 63122
Buggy source:
public static byte[] getStructBytes(Object val){
  ScriptBuilder sb=null;
  try {
    sb=new ScriptBuilder();
    List list=((Struct)val).list;
    sb.add(Type.StructType.getValue());
    sb.add(Helper.BigInt2Bytes(BigInteger.valueOf(list.size())));
    for (int i=0; i < list.size(); i++) {
      if (list.get(i) instanceof byte[]) {
        sb.add(Type.ByteArrayType.getValue());
        sb.push((byte[])list.get(i));
      }
 else       if (list.get(i) instanceof String) {
        sb.add(Type.ByteArrayType.getValue());
        sb.push(((String)list.get(i)).getBytes());
      }
 else       if (list.get(i) instanceof Integer) {
        sb.add(Type.ByteArrayType.getValue());
        sb.push(Helper.BigInt2Bytes(BigInteger.valueOf((Integer)list.get(i))));
      }
 else       if (list.get(i) instanceof Long) {
        sb.add(Type.ByteArrayType.getValue());
        sb.push(Helper.BigInt2Bytes(BigInteger.valueOf((Long)list.get(i))));
      }
 else {
        throw new SDKException(ErrorCode.ParamError);
      }
    }
  }
 catch (  SDKException e) {
    e.printStackTrace();
  }
  return sb.toArray();
}

Fixed version (ground truth):
public static byte[] getStructBytes(Object val){
  ScriptBuilder sb=null;
  try {
    sb=new ScriptBuilder();
    List list=((Struct)val).list;
    sb.add(Type.StructType.getValue());
    sb.add(Helper.BigIntToNeoBytes(BigInteger.valueOf(list.size())));
    for (int i=0; i < list.size(); i++) {
      if (list.get(i) instanceof byte[]) {
        sb.add(Type.ByteArrayType.getValue());
        sb.push((byte[])list.get(i));
      }
 else       if (list.get(i) instanceof String) {
        sb.add(Type.ByteArrayType.getValue());
        sb.push(((String)list.get(i)).getBytes());
      }
 else       if (list.get(i) instanceof Integer) {
        sb.add(Type.ByteArrayType.getValue());
        sb.push(Helper.BigIntToNeoBytes(BigInteger.valueOf((Integer)list.get(i))));
      }
 else       if (list.get(i) instanceof Long) {
        sb.add(Type.ByteArrayType.getValue());
        sb.push(Helper.BigIntToNeoBytes(BigInteger.valueOf((Long)list.get(i))));
      }
 else {
        throw new SDKException(ErrorCode.ParamError);
      }
    }
  }
 catch (  SDKException e) {
    e.printStackTrace();
  }
  return sb.toArray();
}
Program: 63123
Project: 63123
Buggy source:
public static byte[] getMapBytes(Object val){
  ScriptBuilder sb=null;
  try {
    sb=new ScriptBuilder();
    Map<String,Object> map=(Map)val;
    sb.add(Type.MapType.getValue());
    sb.add(Helper.BigInt2Bytes(BigInteger.valueOf(map.size())));
    for (    Map.Entry e : map.entrySet()) {
      sb.add(Type.ByteArrayType.getValue());
      sb.push(((String)e.getKey()).getBytes());
      if (e.getValue() instanceof byte[]) {
        sb.add(Type.ByteArrayType.getValue());
        sb.push((byte[])e.getValue());
      }
 else       if (e.getValue() instanceof String) {
        sb.add(Type.ByteArrayType.getValue());
        sb.push(((String)e.getValue()).getBytes());
      }
 else       if (e.getValue() instanceof Integer) {
        sb.add(Type.IntegerType.getValue());
        sb.push(Helper.BigInt2Bytes(BigInteger.valueOf((Integer)e.getValue())));
      }
 else       if (e.getValue() instanceof Long) {
        sb.add(Type.IntegerType.getValue());
        sb.push(Helper.BigInt2Bytes(BigInteger.valueOf((Long)e.getValue())));
      }
 else {
        throw new SDKException(ErrorCode.ParamError);
      }
    }
  }
 catch (  SDKException e) {
    e.printStackTrace();
  }
  return sb.toArray();
}

Fixed version (ground truth):
public static byte[] getMapBytes(Object val){
  ScriptBuilder sb=null;
  try {
    sb=new ScriptBuilder();
    Map<String,Object> map=(Map)val;
    sb.add(Type.MapType.getValue());
    sb.add(Helper.BigIntToNeoBytes(BigInteger.valueOf(map.size())));
    for (    Map.Entry e : map.entrySet()) {
      sb.add(Type.ByteArrayType.getValue());
      sb.push(((String)e.getKey()).getBytes());
      if (e.getValue() instanceof byte[]) {
        sb.add(Type.ByteArrayType.getValue());
        sb.push((byte[])e.getValue());
      }
 else       if (e.getValue() instanceof String) {
        sb.add(Type.ByteArrayType.getValue());
        sb.push(((String)e.getValue()).getBytes());
      }
 else       if (e.getValue() instanceof Integer) {
        sb.add(Type.IntegerType.getValue());
        sb.push(Helper.BigIntToNeoBytes(BigInteger.valueOf((Integer)e.getValue())));
      }
 else       if (e.getValue() instanceof Long) {
        sb.add(Type.IntegerType.getValue());
        sb.push(Helper.BigIntToNeoBytes(BigInteger.valueOf((Long)e.getValue())));
      }
 else {
        throw new SDKException(ErrorCode.ParamError);
      }
    }
  }
 catch (  SDKException e) {
    e.printStackTrace();
  }
  return sb.toArray();
}
Program: 63124
Project: 63124
Buggy source:
/** 
 * @param list
 * @return
 */
public static byte[] createCodeParamsScript(List<Object> list){
  ScriptBuilder sb=new ScriptBuilder();
  try {
    for (int i=list.size() - 1; i >= 0; i--) {
      Object val=list.get(i);
      if (val instanceof byte[]) {
        sb.push((byte[])val);
      }
 else       if (val instanceof Boolean) {
        sb.push((Boolean)val);
      }
 else       if (val instanceof Integer) {
        sb.push(Helper.BigInt2Bytes(BigInteger.valueOf((int)val)));
      }
 else       if (val instanceof Long) {
        sb.push(Helper.BigInt2Bytes(BigInteger.valueOf((Long)val)));
      }
 else       if (val instanceof BigInteger) {
        sb.push((BigInteger)val);
      }
 else       if (val instanceof Map) {
        byte[] bys=getMapBytes(val);
        sb.push(bys);
      }
 else       if (val instanceof Struct) {
        byte[] bys=getStructBytes(val);
        sb.push(bys);
      }
 else       if (val instanceof List) {
        List tmp=(List)val;
        createCodeParamsScript(sb,tmp);
        sb.push(new BigInteger(String.valueOf(tmp.size())));
        sb.pushPack();
      }
 else {
      }
    }
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
  return sb.toArray();
}

Fixed version (ground truth):
/** 
 * @param list
 * @return
 */
public static byte[] createCodeParamsScript(List<Object> list){
  ScriptBuilder sb=new ScriptBuilder();
  try {
    for (int i=list.size() - 1; i >= 0; i--) {
      Object val=list.get(i);
      if (val instanceof byte[]) {
        sb.push((byte[])val);
      }
 else       if (val instanceof Boolean) {
        sb.push((Boolean)val);
      }
 else       if (val instanceof Integer) {
        sb.push(Helper.BigIntToNeoBytes(BigInteger.valueOf((int)val)));
      }
 else       if (val instanceof Long) {
        sb.push(Helper.BigIntToNeoBytes(BigInteger.valueOf((Long)val)));
      }
 else       if (val instanceof BigInteger) {
        sb.push((BigInteger)val);
      }
 else       if (val instanceof Map) {
        byte[] bys=getMapBytes(val);
        sb.push(bys);
      }
 else       if (val instanceof Struct) {
        byte[] bys=getStructBytes(val);
        sb.push(bys);
      }
 else       if (val instanceof List) {
        List tmp=(List)val;
        createCodeParamsScript(sb,tmp);
        sb.push(new BigInteger(String.valueOf(tmp.size())));
        sb.pushPack();
      }
 else {
      }
    }
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
  return sb.toArray();
}
Program: 63125
Project: 63125
Buggy source:
@Test public void bigInt2Bytes(){
  BigInteger bigInteger=BigInteger.valueOf(1000000000000L);
  String aa=Helper.toHexString(Helper.BigInt2Bytes(bigInteger));
  System.out.println(aa);
  BigInteger bb=Helper.BigIntFromBytes(Helper.hexToBytes(aa));
  assertTrue(bigInteger.equals(bb));
}

Fixed version (ground truth):
@Test public void bigInt2Bytes(){
  BigInteger bigInteger=BigInteger.valueOf(1000000000000L);
  String aa=Helper.toHexString(Helper.BigIntToNeoBytes(bigInteger));
  System.out.println(aa);
  BigInteger bb=Helper.BigIntFromNeoBytes(Helper.hexToBytes(aa));
  assertTrue(bigInteger.equals(bb));
}
Program: 63126
Project: 63126
Buggy source:
public Object sendTransaction(String contractAddr,Account acct,Account payerAcct,long gaslimit,long gasprice,AbiFunction func,boolean preExec) throws Exception {
  byte[] params=BuildParams.serializeAbiFunction(func);
  if (preExec) {
    Transaction tx=sdk.vm().makeInvokeCodeTransaction(contractAddr,null,params,null,0,0);
    if (acct != null) {
      sdk.signTx(tx,new Account[][]{{acct}});
    }
    Object obj=sdk.getConnect().sendRawTransactionPreExec(tx.toHexString());
    return obj;
  }
 else {
    String payer=payerAcct.getAddressU160().toBase58();
    Transaction tx=sdk.vm().makeInvokeCodeTransaction(contractAddr,null,params,payer,gaslimit,gasprice);
    sdk.signTx(tx,new Account[][]{{acct}});
    if (!payer.equals(payerAcct.getAddressU160().toBase58())) {
      sdk.addSign(tx,payerAcct);
    }
    boolean b=sdk.getConnect().sendRawTransaction(tx.toHexString());
    if (!b) {
      throw new SDKException(ErrorCode.SendRawTxError);
    }
    return tx.hash().toHexString();
  }
}

Fixed version (ground truth):
public Object sendTransaction(String contractAddr,Account acct,Account payerAcct,long gaslimit,long gasprice,AbiFunction func,boolean preExec) throws Exception {
  byte[] params;
  if (func != null) {
    params=BuildParams.serializeAbiFunction(func);
  }
 else {
    params=new byte[]{};
  }
  if (preExec) {
    Transaction tx=sdk.vm().makeInvokeCodeTransaction(contractAddr,null,params,null,0,0);
    if (acct != null) {
      sdk.signTx(tx,new Account[][]{{acct}});
    }
    Object obj=sdk.getConnect().sendRawTransactionPreExec(tx.toHexString());
    return obj;
  }
 else {
    String payer=payerAcct.getAddressU160().toBase58();
    Transaction tx=sdk.vm().makeInvokeCodeTransaction(contractAddr,null,params,payer,gaslimit,gasprice);
    sdk.signTx(tx,new Account[][]{{acct}});
    if (!payer.equals(payerAcct.getAddressU160().toBase58())) {
      sdk.addSign(tx,payerAcct);
    }
    boolean b=sdk.getConnect().sendRawTransaction(tx.toHexString());
    if (!b) {
      throw new SDKException(ErrorCode.SendRawTxError);
    }
    return tx.hash().toHexString();
  }
}
Program: 63127
Project: 63127
Buggy source:
public Object sendTransaction(String contractAddr,Account acct,Account payerAcct,long gaslimit,long gasprice,AbiFunction func,boolean preExec) throws Exception {
  byte[] params;
  if (func != null) {
    params=BuildParams.serializeAbiFunction(func);
  }
 else {
    params=new byte[]{};
  }
  if (preExec) {
    Transaction tx=sdk.vm().makeInvokeCodeTransaction(contractAddr,null,params,null,0,0);
    if (acct != null) {
      sdk.signTx(tx,new Account[][]{{acct}});
    }
    Object obj=sdk.getConnect().sendRawTransactionPreExec(tx.toHexString());
    return obj;
  }
 else {
    String payer=payerAcct.getAddressU160().toBase58();
    Transaction tx=sdk.vm().makeInvokeCodeTransaction(contractAddr,null,params,payer,gaslimit,gasprice);
    sdk.signTx(tx,new Account[][]{{acct}});
    if (!payer.equals(payerAcct.getAddressU160().toBase58())) {
      sdk.addSign(tx,payerAcct);
    }
    boolean b=sdk.getConnect().sendRawTransaction(tx.toHexString());
    if (!b) {
      throw new SDKException(ErrorCode.SendRawTxError);
    }
    return tx.hash().toHexString();
  }
}

Fixed version (ground truth):
public Object sendTransaction(String contractAddr,Account acct,Account payerAcct,long gaslimit,long gasprice,AbiFunction func,boolean preExec) throws Exception {
  byte[] params;
  if (func != null) {
    params=BuildParams.serializeAbiFunction(func);
  }
 else {
    params=new byte[]{};
  }
  if (preExec) {
    Transaction tx=sdk.vm().makeInvokeCodeTransaction(contractAddr,null,params,null,0,0);
    if (acct != null) {
      sdk.signTx(tx,new Account[][]{{acct}});
    }
    Object obj=sdk.getConnect().sendRawTransactionPreExec(tx.toHexString());
    return obj;
  }
 else {
    String payer=payerAcct.getAddressU160().toBase58();
    Transaction tx=sdk.vm().makeInvokeCodeTransaction(contractAddr,null,params,payer,gaslimit,gasprice);
    sdk.signTx(tx,new Account[][]{{acct}});
    if (!acct.equals(payerAcct.getAddressU160().toBase58())) {
      sdk.addSign(tx,payerAcct);
    }
    boolean b=sdk.getConnect().sendRawTransaction(tx.toHexString());
    if (!b) {
      throw new SDKException(ErrorCode.SendRawTxError);
    }
    return tx.hash().toHexString();
  }
}
Program: 63128
Project: 63128
Buggy source:
public static ProgramInfo getProgramInfo(byte[] program) throws IOException {
  ProgramInfo info=new ProgramInfo();
  if (program.length <= 2) {
  }
  byte end=program[program.length - 1];
  byte[] temp=new byte[program.length - 1];
  System.arraycopy(program,0,temp,0,program.length - 1);
  ByteArrayInputStream bais=new ByteArrayInputStream(temp);
  BinaryReader reader=new BinaryReader(bais);
  if (end == ScriptOp.OP_CHECKSIG.getByte()) {
    try {
      byte[] publicKey=readBytes(reader);
      info.setPublicKey(new byte[][]{publicKey});
      info.setM((short)1);
    }
 catch (    IOException e) {
      e.printStackTrace();
    }
  }
 else   if (end == ScriptOp.OP_CHECKMULTISIG.getByte()) {
    short m=0;
    try {
      m=readNum(reader);
    }
 catch (    SDKException e) {
      e.printStackTrace();
    }
    byte[][] pub=new byte[m][];
    for (int i=0; i < (int)m; i++) {
      pub[i]=readBytes(reader);
    }
    info.setPublicKey(pub);
    List<byte[]> buffer=new ArrayList();
    while (true) {
      ScriptOp code=readOpCode(reader);
      if (code == ScriptOp.OP_CHECKMULTISIG) {
        readOpCode(reader);
        break;
      }
 else       if (code == ScriptOp.OP_0) {
        readOpCode(reader);
        BigInteger bint=BigInteger.valueOf(0);
        buffer.add(Helper.BigInt2Bytes(bint));
      }
 else {
        int num=(int)code.getByte() - (int)ScriptOp.OP_1.getByte() + 1;
        if (num >= 1 && num <= 16) {
          readOpCode(reader);
          BigInteger bint=BigInteger.valueOf(num);
          buffer.add(Helper.BigInt2Bytes(bint));
        }
 else {
          buffer.add(readBytes(reader));
        }
      }
    }
    byte[][] buffers=new byte[buffer.size()][];
    for (int i=0; i < buffer.size(); i++) {
      buffers[i]=buffer.get(i);
    }
    BigInteger bint=new BigInteger(buffers[buffers.length - 1]);
    long n=bint.longValue();
    if (1 <= m && m <= n && n <= 1024) {
    }
    info.setPublicKey(buffers);
  }
  return info;
}

Fixed version (ground truth):
public static ProgramInfo getProgramInfo(byte[] program) throws IOException {
  ProgramInfo info=new ProgramInfo();
  if (program.length <= 2) {
  }
  byte end=program[program.length - 1];
  byte[] temp=new byte[program.length - 1];
  System.arraycopy(program,0,temp,0,program.length - 1);
  ByteArrayInputStream bais=new ByteArrayInputStream(temp);
  BinaryReader reader=new BinaryReader(bais);
  if (end == ScriptOp.OP_CHECKSIG.getByte()) {
    try {
      byte[] publicKey=readBytes(reader);
      info.setPublicKey(new byte[][]{publicKey});
      info.setM((short)1);
    }
 catch (    IOException e) {
      e.printStackTrace();
    }
  }
 else   if (end == ScriptOp.OP_CHECKMULTISIG.getByte()) {
    short m=0;
    int len=program[program.length - 2] - ScriptOp.OP_PUSH1.getByte() + 1;
    try {
      m=reader.readByte();
    }
 catch (    Exception e) {
      e.printStackTrace();
    }
    byte[][] pub=new byte[len][];
    for (int i=0; i < (int)len; i++) {
      pub[i]=reader.readVarBytes();
    }
    info.setPublicKey(pub);
    info.setM(m);
  }
  return info;
}
Program: 63129
Project: 63129
Buggy source:
public static short readNum(BinaryReader reader) throws IOException, SDKException {
  ScriptOp code=readOpCode(reader);
  if (code == ScriptOp.OP_0) {
    readOpCode(reader);
    return 0;
  }
 else {
    int num=(int)code.getByte() - (int)ScriptOp.OP_1.getByte() + 1;
    if (num >= 1 && num <= 16) {
      readOpCode(reader);
      return (short)num;
    }
  }
  byte[] buff=readBytes(reader);
  BigInteger bint=Helper.BigIntFromBytes(buff);
  long num=bint.longValue();
  if (num > Short.MAX_VALUE || num < 16) {
    throw new SDKException(ErrorCode.ParamErr("String_Node_Str"));
  }
  return (short)num;
}

Fixed version (ground truth):
public static short readNum(BinaryReader reader) throws IOException, SDKException {
  ScriptOp code=readOpCode(reader);
  if (code == ScriptOp.OP_PUSH0) {
    readOpCode(reader);
    return 0;
  }
 else {
    int num=(int)code.getByte() - (int)ScriptOp.OP_PUSH1.getByte() + 1;
    if (num >= 1 && num <= 16) {
      readOpCode(reader);
      return (short)num;
    }
  }
  byte[] buff=readBytes(reader);
  BigInteger bint=Helper.BigIntFromBytes(buff);
  long num=bint.longValue();
  if (num > Short.MAX_VALUE || num < 16) {
    throw new SDKException(ErrorCode.ParamErr("String_Node_Str"));
  }
  return (short)num;
}
Program: 63130
Project: 63130
Buggy source:
/** 
 * @param peerPubkey
 * @param addr
 * @return
 */
public VoteInfo getVoteInfo(String peerPubkey,Address addr){
  byte[] peerPubkeyPrefix=Helper.hexToBytes(peerPubkey);
  byte[] address=addr.toArray();
  byte[] voteInfoPool=VOTE_INFO_POOL.getBytes();
  byte[] key=new byte[voteInfoPool.length + peerPubkeyPrefix.length + address.length];
  System.arraycopy(voteInfoPool,0,key,0,voteInfoPool.length);
  System.arraycopy(peerPubkeyPrefix,0,key,voteInfoPool.length,peerPubkeyPrefix.length);
  System.arraycopy(address,0,key,voteInfoPool.length + peerPubkeyPrefix.length,address.length);
  String res=null;
  try {
    res=sdk.getConnect().getStorage(Helper.reverse(contractAddress),Helper.toHexString(key));
    if (!res.equals("String_Node_Str")) {
      return Serializable.from(Helper.hexToBytes(res),VoteInfo.class);
    }
  }
 catch (  ConnectorException e) {
    return null;
  }
catch (  IOException e) {
    e.printStackTrace();
  }
catch (  IllegalAccessException e) {
    e.printStackTrace();
  }
catch (  InstantiationException e) {
    e.printStackTrace();
  }
  return null;
}

Fixed version (ground truth):
/** 
 * @param peerPubkey
 * @param addr
 * @return
 */
public VoteInfo getVoteInfo(String peerPubkey,Address addr){
  byte[] peerPubkeyPrefix=Helper.hexToBytes(peerPubkey);
  byte[] address=addr.toArray();
  byte[] voteInfoPool=VOTE_INFO_POOL.getBytes();
  byte[] key=new byte[voteInfoPool.length + peerPubkeyPrefix.length + address.length];
  System.arraycopy(voteInfoPool,0,key,0,voteInfoPool.length);
  System.arraycopy(peerPubkeyPrefix,0,key,voteInfoPool.length,peerPubkeyPrefix.length);
  System.arraycopy(address,0,key,voteInfoPool.length + peerPubkeyPrefix.length,address.length);
  String res=null;
  try {
    res=sdk.getConnect().getStorage(Helper.reverse(contractAddress),Helper.toHexString(key));
    if (res != null && !res.equals("String_Node_Str")) {
      return Serializable.from(Helper.hexToBytes(res),VoteInfo.class);
    }
  }
 catch (  ConnectorException e) {
    return null;
  }
catch (  IOException e) {
    e.printStackTrace();
  }
catch (  IllegalAccessException e) {
    e.printStackTrace();
  }
catch (  InstantiationException e) {
    e.printStackTrace();
  }
  return null;
}
Program: 63132
Project: 63132
Buggy source:
public static OntSdk getOntSdk() throws Exception {
  String ip="String_Node_Str";
  String restUrl=ip + "String_Node_Str" + "String_Node_Str";
  String rpcUrl=ip + "String_Node_Str" + "String_Node_Str";
  String wsUrl=ip + "String_Node_Str" + "String_Node_Str";
  OntSdk wm=OntSdk.getInstance();
  wm.setRpc(rpcUrl);
  wm.setRestful(restUrl);
  wm.setDefaultConnect(wm.getRestful());
  wm.neovm().nep5().setContractAddress("String_Node_Str");
  wm.openWalletFile("String_Node_Str");
  return wm;
}

Fixed version (ground truth):
public static OntSdk getOntSdk() throws Exception {
  String ip="String_Node_Str";
  String restUrl=ip + "String_Node_Str" + "String_Node_Str";
  String rpcUrl=ip + "String_Node_Str" + "String_Node_Str";
  String wsUrl=ip + "String_Node_Str" + "String_Node_Str";
  OntSdk wm=OntSdk.getInstance();
  wm.setRpc(rpcUrl);
  wm.setRestful(restUrl);
  wm.setDefaultConnect(wm.getRestful());
  wm.neovm().nep5().setContractAddress(Helper.reverse("String_Node_Str"));
  wm.openWalletFile("String_Node_Str");
  return wm;
}
Program: 63133
Project: 63133
Buggy source:
public Identity getDefaultIdentity(){
  for (  Identity e : getIdentities()) {
    if (e.isDefault) {
      return e;
    }
  }
  return null;
}

Fixed version (ground truth):
public String getDefaultIdentity(){
  for (  Identity e : getIdentities()) {
    if (e.isDefault) {
      return e.ontid;
    }
  }
  return null;
}
Program: 63134
Project: 63134
Buggy source:
public Account getDefaultAccount(){
  for (  Account e : getAccounts()) {
    if (e.isDefault) {
      return e;
    }
  }
  return null;
}

Fixed version (ground truth):
public String getDefaultAccount(){
  for (  Account e : getAccounts()) {
    if (e.isDefault) {
      return e.address;
    }
  }
  return null;
}
Program: 63135
Project: 63135
Buggy source:
/** 
 * @param ontid
 * @param password
 * @param contractAddr
 * @param funcName
 * @param keyNo
 * @return
 * @throws Exception
 */
public String verifyToken(String ontid,String password,byte[] salt,long keyNo,String contractAddr,String funcName) throws Exception {
  if (ontid == null || ontid.equals("String_Node_Str") || password == null || password.equals("String_Node_Str") || contractAddr == null || contractAddr.equals("String_Node_Str") || funcName == null || funcName.equals("String_Node_Str")) {
    throw new SDKException(ErrorCode.ParamErr("String_Node_Str"));
  }
  if (keyNo < 0) {
    throw new SDKException(ErrorCode.ParamErr("String_Node_Str"));
  }
  Transaction tx=makeVerifyToken(ontid,contractAddr,funcName,keyNo);
  sdk.signTx(tx,ontid,password,salt);
  Object obj=sdk.getConnect().sendRawTransactionPreExec(tx.toHexString());
  if (Integer.parseInt(((JSONObject)obj).getString("String_Node_Str")) != 1) {
    throw new SDKException(ErrorCode.OtherError("String_Node_Str" + obj));
  }
  return tx.hash().toHexString();
}

Fixed version (ground truth):
/** 
 * @param ontid
 * @param password
 * @param contractAddr
 * @param funcName
 * @param keyNo
 * @return
 * @throws Exception
 */
public String verifyToken(String ontid,String password,byte[] salt,long keyNo,String contractAddr,String funcName) throws Exception {
  if (ontid == null || ontid.equals("String_Node_Str") || password == null || password.equals("String_Node_Str") || contractAddr == null || contractAddr.equals("String_Node_Str") || funcName == null || funcName.equals("String_Node_Str")) {
    throw new SDKException(ErrorCode.ParamErr("String_Node_Str"));
  }
  if (keyNo < 0) {
    throw new SDKException(ErrorCode.ParamErr("String_Node_Str"));
  }
  Transaction tx=makeVerifyToken(ontid,contractAddr,funcName,keyNo);
  sdk.signTx(tx,ontid,password,salt);
  Object obj=sdk.getConnect().sendRawTransactionPreExec(tx.toHexString());
  if (Integer.parseInt(((JSONObject)obj).getString("String_Node_Str")) != 1) {
    throw new SDKException(ErrorCode.OtherError("String_Node_Str" + obj));
  }
  return ((JSONObject)obj).getString("String_Node_Str");
}
Program: 63136
Project: 63136
Buggy source:
/** 
 * @param adminOntId
 * @param password
 * @param payerAcct
 * @param gaslimit
 * @param gasprice
 * @return
 * @throws Exception
 */
public String commitDpos(String adminOntId,String password,byte[] salt,Account payerAcct,long gaslimit,long gasprice) throws Exception {
  Transaction tx=sdk.vm().buildNativeParams(new Address(Helper.hexToBytes(contractAddress)),"String_Node_Str",new byte[]{},payerAcct.getAddressU160().toBase58(),gaslimit,gasprice);
  sdk.signTx(tx,adminOntId,password,salt);
  sdk.addSign(tx,payerAcct);
  boolean b=sdk.getConnect().sendRawTransaction(tx.toHexString());
  if (b) {
    return tx.hash().toString();
  }
  return null;
}

Fixed version (ground truth):
/** 
 * @param adminOntId
 * @param password
 * @param payerAcct
 * @param gaslimit
 * @param gasprice
 * @return
 * @throws Exception
 */
public String commitDpos(String adminOntId,String password,byte[] salt,Account payerAcct,long gaslimit,long gasprice) throws Exception {
  Transaction tx=sdk.vm().buildNativeParams(new Address(Helper.hexToBytes(contractAddress)),"String_Node_Str",new byte[]{0},payerAcct.getAddressU160().toBase58(),gaslimit,gasprice);
  sdk.signTx(tx,adminOntId,password,salt);
  sdk.addSign(tx,payerAcct);
  boolean b=sdk.getConnect().sendRawTransaction(tx.toHexString());
  if (b) {
    return tx.hash().toString();
  }
  return null;
}
Program: 63138
Project: 63138
Buggy source:
public Object sendTransaction(String contractAddr,Account acct,Account payerAcct,long gaslimit,long gasprice,AbiFunction func,boolean preExec) throws Exception {
  byte[] params=BuildParams.serializeAbiFunction(func);
  if (preExec) {
    Transaction tx=sdk.vm().makeInvokeCodeTransaction(contractAddr,null,params,null,0,0);
    sdk.signTx(tx,new Account[][]{{acct}});
    Object obj=sdk.getConnect().sendRawTransactionPreExec(tx.toHexString());
    return obj;
  }
 else {
    String payer=payerAcct.getAddressU160().toBase58();
    Transaction tx=sdk.vm().makeInvokeCodeTransaction(contractAddr,null,params,payer,gaslimit,gasprice);
    sdk.signTx(tx,new Account[][]{{acct}});
    if (!payer.equals(payerAcct.getAddressU160().toBase58())) {
      sdk.addSign(tx,payerAcct);
    }
    boolean b=sdk.getConnect().sendRawTransaction(tx.toHexString());
    if (!b) {
      throw new SDKException(ErrorCode.SendRawTxError);
    }
    return tx.hash().toHexString();
  }
}

Fixed version (ground truth):
public Object sendTransaction(String contractAddr,Account acct,Account payerAcct,long gaslimit,long gasprice,AbiFunction func,boolean preExec) throws Exception {
  byte[] params=BuildParams.serializeAbiFunction(func);
  if (preExec) {
    Transaction tx=sdk.vm().makeInvokeCodeTransaction(contractAddr,null,params,null,0,0);
    if (acct != null) {
      sdk.signTx(tx,new Account[][]{{acct}});
    }
    Object obj=sdk.getConnect().sendRawTransactionPreExec(tx.toHexString());
    return obj;
  }
 else {
    String payer=payerAcct.getAddressU160().toBase58();
    Transaction tx=sdk.vm().makeInvokeCodeTransaction(contractAddr,null,params,payer,gaslimit,gasprice);
    sdk.signTx(tx,new Account[][]{{acct}});
    if (!payer.equals(payerAcct.getAddressU160().toBase58())) {
      sdk.addSign(tx,payerAcct);
    }
    boolean b=sdk.getConnect().sendRawTransaction(tx.toHexString());
    if (!b) {
      throw new SDKException(ErrorCode.SendRawTxError);
    }
    return tx.hash().toHexString();
  }
}
Program: 63139
Project: 63139
Buggy source:
/** 
 * @param ontid
 * @param recoveryOntid
 * @param password
 * @param newpubkey
 * @param payer
 * @param gaslimit
 * @param gasprice
 * @return
 * @throws Exception
 */
public Transaction makeAddPubKey(String ontid,String recoveryOntid,String password,String newpubkey,String payer,long gaslimit,long gasprice) throws Exception {
  if (ontid == null || ontid.equals("String_Node_Str") || payer == null || payer.equals("String_Node_Str") || newpubkey == null || newpubkey.equals("String_Node_Str")) {
    throw new SDKException(ErrorCode.ParamErr("String_Node_Str"));
  }
  if (gasprice < 0 || gaslimit < 0) {
    throw new SDKException(ErrorCode.ParamErr("String_Node_Str"));
  }
  byte[] parabytes;
  String recoveryAddr=recoveryOntid.replace(Common.didont,"String_Node_Str");
  if (recoveryAddr == null) {
    AccountInfo info=sdk.getWalletMgr().getAccountInfo(ontid,password);
    byte[] pk=Helper.hexToBytes(info.pubkey);
    parabytes=BuildParams.buildParams(ontid.getBytes(),Helper.hexToBytes(newpubkey),pk);
  }
 else {
    parabytes=BuildParams.buildParams(ontid,Helper.hexToBytes(newpubkey),Address.decodeBase58(recoveryAddr).toArray());
  }
  Transaction tx=sdk.vm().makeInvokeCodeTransaction(contractAddress,"String_Node_Str",parabytes,VmType.Native.value(),payer,gaslimit,gasprice);
  return tx;
}

Fixed version (ground truth):
/** 
 * @param ontid
 * @param recoveryOntid
 * @param password
 * @param newpubkey
 * @param payer
 * @param gaslimit
 * @param gasprice
 * @return
 * @throws Exception
 */
public Transaction makeAddPubKey(String ontid,String recoveryOntid,String password,String newpubkey,String payer,long gaslimit,long gasprice) throws Exception {
  if (ontid == null || ontid.equals("String_Node_Str") || payer == null || payer.equals("String_Node_Str") || newpubkey == null || newpubkey.equals("String_Node_Str")) {
    throw new SDKException(ErrorCode.ParamErr("String_Node_Str"));
  }
  if (gasprice < 0 || gaslimit < 0) {
    throw new SDKException(ErrorCode.ParamErr("String_Node_Str"));
  }
  byte[] parabytes;
  if (recoveryOntid == null) {
    AccountInfo info=sdk.getWalletMgr().getAccountInfo(ontid,password);
    byte[] pk=Helper.hexToBytes(info.pubkey);
    parabytes=BuildParams.buildParams(ontid.getBytes(),Helper.hexToBytes(newpubkey),pk);
  }
 else {
    parabytes=BuildParams.buildParams(ontid,Helper.hexToBytes(newpubkey),Address.decodeBase58(recoveryOntid.replace(Common.didont,"String_Node_Str")).toArray());
  }
  Transaction tx=sdk.vm().makeInvokeCodeTransaction(contractAddress,"String_Node_Str",parabytes,VmType.Native.value(),payer,gaslimit,gasprice);
  return tx;
}
Program: 63140
Project: 63140
Buggy source:
@Test public void sendApprove() throws Exception {
  com.github.ontio.account.Account sendAcct1=ontSdk.getWalletMgr().getAccount(info1.address,password);
  com.github.ontio.account.Account sendAcct2=ontSdk.getWalletMgr().getAccount(info1.address,password);
  com.github.ontio.account.Account payerAcct=ontSdk.getWalletMgr().getAccount(payer.address,password);
  ontSdk.nativevm().ont().sendApprove(sendAcct1,info2.address,10L,payerAcct,ontSdk.DEFAULT_GAS_LIMIT,0);
  long info1balance=ontSdk.nativevm().ont().queryBalanceOf(info1.address);
  long info2balance=ontSdk.nativevm().ont().queryBalanceOf(info2.address);
  Thread.sleep(6000);
  long allo=ontSdk.nativevm().ont().queryAllowance(info1.address,info2.address);
  Assert.assertTrue(allo > 0);
  ontSdk.nativevm().ont().sendTransferFrom(sendAcct2,info1.address,info2.address,10L,payerAcct,ontSdk.DEFAULT_GAS_LIMIT,0);
  Thread.sleep(6000);
  long info1balance2=ontSdk.nativevm().ont().queryBalanceOf(info1.address);
  long info2balance2=ontSdk.nativevm().ont().queryBalanceOf(info2.address);
  Assert.assertTrue((info1balance - info1balance2) == 10);
  Assert.assertTrue((info2balance2 - info2balance) == 10);
}

Fixed version (ground truth):
@Test public void sendApprove() throws Exception {
  com.github.ontio.account.Account sendAcct1=ontSdk.getWalletMgr().getAccount(info1.address,password);
  com.github.ontio.account.Account sendAcct2=ontSdk.getWalletMgr().getAccount(info2.address,password);
  com.github.ontio.account.Account payerAcct=ontSdk.getWalletMgr().getAccount(payer.address,password);
  ontSdk.nativevm().ont().sendApprove(sendAcct1,sendAcct2.getAddressU160().toBase58(),10L,payerAcct,ontSdk.DEFAULT_GAS_LIMIT,0);
  long info1balance=ontSdk.nativevm().ont().queryBalanceOf(sendAcct1.getAddressU160().toBase58());
  long info2balance=ontSdk.nativevm().ont().queryBalanceOf(sendAcct2.getAddressU160().toBase58());
  Thread.sleep(6000);
  long allo=ontSdk.nativevm().ont().queryAllowance(sendAcct1.getAddressU160().toBase58(),sendAcct2.getAddressU160().toBase58());
  Assert.assertTrue(allo == 10);
  ontSdk.nativevm().ont().sendTransferFrom(sendAcct2,info1.address,sendAcct2.getAddressU160().toBase58(),10L,payerAcct,ontSdk.DEFAULT_GAS_LIMIT,0);
  Thread.sleep(6000);
  long info1balance2=ontSdk.nativevm().ont().queryBalanceOf(info1.address);
  long info2balance2=ontSdk.nativevm().ont().queryBalanceOf(info2.address);
  Assert.assertTrue((info1balance - info1balance2) == 10);
  Assert.assertTrue((info2balance2 - info2balance) == 10);
}
Program: 63141
Project: 63141
Buggy source:
@Test public void createIdentity() throws Exception {
  Identity identity=walletMgr.createIdentity(password);
  assertNotNull(identity);
  assertNotNull(identity.ontid);
  assertNotEquals(identity.ontid,"String_Node_Str");
}

Fixed version (ground truth):
@Test public void createIdentity() throws Exception {
  Identity identity=walletMgr.createIdentity(password);
  com.github.ontio.account.Account account=walletMgr.getAccount(identity.ontid,password);
  assertNotNull(account);
  assertNotNull(identity);
  assertNotNull(identity.ontid);
  assertNotEquals(identity.ontid,"String_Node_Str");
}
Program: 63142
Project: 63142
Buggy source:
public Wallet writeWallet() throws Exception {
  writeFile(filePath,JSON.toJSONString(wallet));
  walletFile=wallet;
  return walletFile;
}

Fixed version (ground truth):
public Wallet writeWallet() throws Exception {
  writeFile(filePath,JSON.toJSONString(walletInMem));
  walletFile=walletInMem.clone();
  return walletFile;
}
Program: 63143
Project: 63143
Buggy source:
private com.github.ontio.account.Account getAccountByAddress(Address address,String password) throws Exception {
  try {
    for (    Account e : wallet.getAccounts()) {
      if (e.address.equals(address.toBase58())) {
        String prikey=com.github.ontio.account.Account.getCtrDecodedPrivateKey(e.key,password,e.address,walletFile.getScrypt().getN(),scheme);
        return new com.github.ontio.account.Account(Helper.hexToBytes(prikey),scheme);
      }
    }
    for (    Identity e : wallet.getIdentities()) {
      if (e.ontid.equals(Common.didont + address.toBase58())) {
        String addr=e.ontid.replace(Common.didont,"String_Node_Str");
        String prikey=com.github.ontio.account.Account.getCtrDecodedPrivateKey(e.controls.get(0).key,password,addr,walletFile.getScrypt().getN(),scheme);
        return new com.github.ontio.account.Account(Helper.hexToBytes(prikey),scheme);
      }
    }
  }
 catch (  Exception e) {
    throw new SDKException(ErrorCode.GetAccountByAddressErr);
  }
  throw new SDKException(ErrorCode.OtherError("String_Node_Str"));
}

Fixed version (ground truth):
private com.github.ontio.account.Account getAccountByAddress(Address address,String password) throws Exception {
  try {
    for (    Account e : walletInMem.getAccounts()) {
      if (e.address.equals(address.toBase58())) {
        String prikey=com.github.ontio.account.Account.getCtrDecodedPrivateKey(e.key,password,e.address,walletFile.getScrypt().getN(),scheme);
        return new com.github.ontio.account.Account(Helper.hexToBytes(prikey),scheme);
      }
    }
    for (    Identity e : walletInMem.getIdentities()) {
      if (e.ontid.equals(Common.didont + address.toBase58())) {
        String addr=e.ontid.replace(Common.didont,"String_Node_Str");
        String prikey=com.github.ontio.account.Account.getCtrDecodedPrivateKey(e.controls.get(0).key,password,addr,walletFile.getScrypt().getN(),scheme);
        return new com.github.ontio.account.Account(Helper.hexToBytes(prikey),scheme);
      }
    }
  }
 catch (  Exception e) {
    throw new SDKException(ErrorCode.GetAccountByAddressErr);
  }
  throw new SDKException(ErrorCode.OtherError("String_Node_Str"));
}
Program: 63144
Project: 63144
Buggy source:
public Identity getDefaultIdentity(){
  for (  Identity e : wallet.getIdentities()) {
    if (e.isDefault) {
      return e;
    }
  }
  return null;
}

Fixed version (ground truth):
public Identity getDefaultIdentity(){
  for (  Identity e : walletInMem.getIdentities()) {
    if (e.isDefault) {
      return e;
    }
  }
  return null;
}
Program: 63145
Project: 63145
Buggy source:
public Account getAccount(String address){
  for (  Account e : wallet.getAccounts()) {
    if (e.address.equals(address)) {
      return e;
    }
  }
  return null;
}

Fixed version (ground truth):
public Account getAccount(String address){
  for (  Account e : walletInMem.getAccounts()) {
    if (e.address.equals(address)) {
      return e;
    }
  }
  return null;
}
Program: 63146
Project: 63146
Buggy source:
public Wallet getWallet(){
  return wallet;
}

Fixed version (ground truth):
/** 
 * @return wallet in memory
 */
public Wallet getWallet(){
  return walletInMem;
}
Program: 63147
Project: 63147
Buggy source:
public Identity importIdentity(String label,String encryptedPrikey,String password,byte[] prefix) throws Exception {
  String prikey=com.github.ontio.account.Account.getCtrDecodedPrivateKey(encryptedPrikey,password,prefix,walletFile.getScrypt().getN(),scheme);
  IdentityInfo info=createIdentity(label,password,Helper.hexToBytes(prikey));
  return getIdentity(info.ontid);
}

Fixed version (ground truth):
public Identity importIdentity(String label,String encryptedPrikey,String password,byte[] salt) throws Exception {
  String prikey=com.github.ontio.account.Account.getCtrDecodedPrivateKey(encryptedPrikey,password,salt,walletFile.getScrypt().getN(),scheme);
  IdentityInfo info=createIdentity(label,password,Helper.hexToBytes(prikey));
  prikey=null;
  return getIdentity(info.ontid);
}
Program: 63148
Project: 63148
Buggy source:
private void addIdentity(Identity idt){
  for (  Identity e : wallet.getIdentities()) {
    if (e.ontid.equals(idt.ontid)) {
      return;
    }
  }
  wallet.getIdentities().add(idt);
}

Fixed version (ground truth):
private void addIdentity(Identity idt){
  for (  Identity e : walletInMem.getIdentities()) {
    if (e.ontid.equals(idt.ontid)) {
      return;
    }
  }
  walletInMem.getIdentities().add(idt);
}
Program: 63150
Project: 63150
Buggy source:
public List<Account> getAccounts(){
  return wallet.getAccounts();
}

Fixed version (ground truth):
public List<Account> getAccounts(){
  return walletInMem.getAccounts();
}
Program: 63151
Project: 63151
Buggy source:
public List<Identity> getIdentitys(){
  return wallet.getIdentities();
}

Fixed version (ground truth):
public List<Identity> getIdentitys(){
  return walletInMem.getIdentities();
}
Program: 63152
Project: 63152
Buggy source:
public Identity getIdentity(String ontid){
  for (  Identity e : wallet.getIdentities()) {
    if (e.ontid.equals(ontid)) {
      return e;
    }
  }
  return null;
}

Fixed version (ground truth):
public Identity getIdentity(String ontid){
  for (  Identity e : walletInMem.getIdentities()) {
    if (e.ontid.equals(ontid)) {
      return e;
    }
  }
  return null;
}
Program: 63153
Project: 63153
Buggy source:
public Identity createIdentityFromPriKey(String password,String prikey) throws Exception {
  IdentityInfo info=createIdentity("String_Node_Str",password,Helper.hexToBytes(prikey));
  return getIdentity(info.ontid);
}

Fixed version (ground truth):
public Identity createIdentityFromPriKey(String password,String prikey) throws Exception {
  IdentityInfo info=createIdentity("String_Node_Str",password,Helper.hexToBytes(prikey));
  prikey=null;
  return getIdentity(info.ontid);
}
Program: 63154
Project: 63154
Buggy source:
private WalletMgr(String path,String label,String password,SignatureScheme scheme) throws Exception {
  this.scheme=scheme;
  this.filePath=path;
  File file=new File(filePath);
  if (!file.exists()) {
    wallet=new Wallet();
    wallet.setCreateTime(new SimpleDateFormat("String_Node_Str").format(new Date()));
    walletFile=new Wallet();
    file.createNewFile();
    createIdentity(label,password);
    writeWallet();
  }
  InputStream inputStream=new FileInputStream(filePath);
  String text=IOUtils.toString(inputStream);
  wallet=JSON.parseObject(text,Wallet.class);
  walletFile=JSON.parseObject(text,Wallet.class);
  if (wallet.getIdentities() == null) {
    wallet.setIdentities(new ArrayList<Identity>());
  }
  if (wallet.getAccounts() == null) {
    wallet.setAccounts(new ArrayList<Account>());
  }
  if (getIdentitys().size() == 0) {
    createIdentity(label,password);
    writeWallet();
  }
}

Fixed version (ground truth):
private WalletMgr(String path,String label,String password,SignatureScheme scheme) throws Exception {
  this.scheme=scheme;
  this.filePath=path;
  File file=new File(filePath);
  if (!file.exists()) {
    walletInMem=new Wallet();
    walletInMem.setCreateTime(new SimpleDateFormat("String_Node_Str").format(new Date()));
    walletFile=new Wallet();
    file.createNewFile();
    createIdentity(label,password);
    writeWallet();
  }
  InputStream inputStream=new FileInputStream(filePath);
  String text=IOUtils.toString(inputStream);
  walletInMem=JSON.parseObject(text,Wallet.class);
  walletFile=JSON.parseObject(text,Wallet.class);
  if (walletInMem.getIdentities() == null) {
    walletInMem.setIdentities(new ArrayList<Identity>());
  }
  if (walletInMem.getAccounts() == null) {
    walletInMem.setAccounts(new ArrayList<Account>());
  }
  if (getIdentitys().size() == 0) {
    createIdentity(label,password);
    writeWallet();
  }
}
Program: 63155
Project: 63155
Buggy source:
public Account getDefaultAccount(){
  for (  Account e : wallet.getAccounts()) {
    if (e.isDefault) {
      return e;
    }
  }
  return null;
}

Fixed version (ground truth):
public Account getDefaultAccount(){
  for (  Account e : walletInMem.getAccounts()) {
    if (e.isDefault) {
      return e;
    }
  }
  return null;
}
Program: 63156
Project: 63156
Buggy source:
/** 
 * @param ontid
 * @return
 * @throws SDKException
 * @throws ConnectorException
 * @throws IOException
 */
public String sendGetPublicKeys(String ontid) throws SDKException, ConnectorException, IOException {
  if (contractAddress == null) {
    throw new SDKException(ErrorCode.NullCodeHash);
  }
  byte[] parabytes=buildParams(ontid.getBytes());
  Transaction tx=sdk.vm().makeInvokeCodeTransaction(contractAddress,"String_Node_Str",parabytes,VmType.Native.value(),null,0,0);
  Object obj=sdk.getConnect().sendRawTransactionPreExec(tx.toHexString());
  String res=((JSONObject)obj).getString("String_Node_Str");
  if (res.equals("String_Node_Str")) {
    throw new SDKException(ErrorCode.ResultIsNull);
  }
  ByteArrayInputStream bais=new ByteArrayInputStream(Helper.hexToBytes(res));
  BinaryReader br=new BinaryReader(bais);
  List pubKeyList=new ArrayList();
  while (true) {
    try {
      Map publicKeyMap=new HashMap();
      publicKeyMap.put("String_Node_Str",ontid + "String_Node_Str" + String.valueOf(br.readInt()));
      byte[] pubKey=br.readVarBytes();
      publicKeyMap.put("String_Node_Str",KeyType.fromLabel(pubKey[0]));
      publicKeyMap.put("String_Node_Str",Curve.fromLabel(pubKey[1]));
      publicKeyMap.put("String_Node_Str",Helper.toHexString(pubKey));
      pubKeyList.add(publicKeyMap);
    }
 catch (    Exception e) {
      break;
    }
  }
  return JSON.toJSONString(pubKeyList);
}

Fixed version (ground truth):
/** 
 * @param ontid
 * @return
 * @throws SDKException
 * @throws ConnectorException
 * @throws IOException
 */
public String sendGetPublicKeys(String ontid) throws SDKException, ConnectorException, IOException {
  if (contractAddress == null) {
    throw new SDKException(ErrorCode.NullCodeHash);
  }
  byte[] parabytes=buildParams(ontid.getBytes());
  Transaction tx=sdk.vm().makeInvokeCodeTransaction(contractAddress,"String_Node_Str",parabytes,VmType.Native.value(),null,0,0);
  Object obj=sdk.getConnect().sendRawTransactionPreExec(tx.toHexString());
  String res=((JSONObject)obj).getString("String_Node_Str");
  if (res.equals("String_Node_Str")) {
    return res;
  }
  ByteArrayInputStream bais=new ByteArrayInputStream(Helper.hexToBytes(res));
  BinaryReader br=new BinaryReader(bais);
  List pubKeyList=new ArrayList();
  while (true) {
    try {
      Map publicKeyMap=new HashMap();
      publicKeyMap.put("String_Node_Str",ontid + "String_Node_Str" + String.valueOf(br.readInt()));
      byte[] pubKey=br.readVarBytes();
      publicKeyMap.put("String_Node_Str",KeyType.fromLabel(pubKey[0]));
      publicKeyMap.put("String_Node_Str",Curve.fromLabel(pubKey[1]));
      publicKeyMap.put("String_Node_Str",Helper.toHexString(pubKey));
      pubKeyList.add(publicKeyMap);
    }
 catch (    Exception e) {
      break;
    }
  }
  return JSON.toJSONString(pubKeyList);
}
Program: 63157
Project: 63157
Buggy source:
public String sendGetAttributes(String ontid) throws SDKException, ConnectorException, IOException {
  if (contractAddress == null) {
    throw new SDKException(ErrorCode.NullCodeHash);
  }
  byte[] parabytes=buildParams(ontid.getBytes());
  Transaction tx=sdk.vm().makeInvokeCodeTransaction(contractAddress,"String_Node_Str",parabytes,VmType.Native.value(),null,0,0);
  Object obj=sdk.getConnect().sendRawTransactionPreExec(tx.toHexString());
  String res=((JSONObject)obj).getString("String_Node_Str");
  if (res.equals("String_Node_Str")) {
    throw new SDKException(ErrorCode.ResultIsNull);
  }
  ByteArrayInputStream bais=new ByteArrayInputStream(Helper.hexToBytes(res));
  BinaryReader br=new BinaryReader(bais);
  List attrsList=new ArrayList();
  while (true) {
    try {
      Map attributeMap=new HashMap();
      attributeMap.put("String_Node_Str",new String(br.readVarBytes()));
      attributeMap.put("String_Node_Str",new String(br.readVarBytes()));
      attributeMap.put("String_Node_Str",new String(br.readVarBytes()));
      attrsList.add(attributeMap);
    }
 catch (    Exception e) {
      break;
    }
  }
  return JSON.toJSONString(attrsList);
}

Fixed version (ground truth):
public String sendGetAttributes(String ontid) throws SDKException, ConnectorException, IOException {
  if (contractAddress == null) {
    throw new SDKException(ErrorCode.NullCodeHash);
  }
  byte[] parabytes=buildParams(ontid.getBytes());
  Transaction tx=sdk.vm().makeInvokeCodeTransaction(contractAddress,"String_Node_Str",parabytes,VmType.Native.value(),null,0,0);
  Object obj=sdk.getConnect().sendRawTransactionPreExec(tx.toHexString());
  String res=((JSONObject)obj).getString("String_Node_Str");
  if (res.equals("String_Node_Str")) {
    return res;
  }
  ByteArrayInputStream bais=new ByteArrayInputStream(Helper.hexToBytes(res));
  BinaryReader br=new BinaryReader(bais);
  List attrsList=new ArrayList();
  while (true) {
    try {
      Map attributeMap=new HashMap();
      attributeMap.put("String_Node_Str",new String(br.readVarBytes()));
      attributeMap.put("String_Node_Str",new String(br.readVarBytes()));
      attributeMap.put("String_Node_Str",new String(br.readVarBytes()));
      attrsList.add(attributeMap);
    }
 catch (    Exception e) {
      break;
    }
  }
  return JSON.toJSONString(attrsList);
}