Program: 63149
Project: 63149
Buggy source:
private com.github.ontio.account.Account createAccount(String label,String password,byte[] privateKey,boolean saveAccountFlag) throws Exception {
  com.github.ontio.account.Account account=new com.github.ontio.account.Account(privateKey,scheme);
  Account acct;
switch (scheme) {
case SHA256WITHECDSA:
    acct=new Account("String_Node_Str",new Object[]{Curve.P256.toString()},"String_Node_Str","String_Node_Str","String_Node_Str");
  break;
case SM3WITHSM2:
acct=new Account("String_Node_Str",new Object[]{Curve.SM2P256V1.toString()},"String_Node_Str","String_Node_Str","String_Node_Str");
break;
default :
throw new SDKException(ErrorCode.OtherError("String_Node_Str"));
}
if (password != null) {
acct.key=account.exportCtrEncryptedPrikey(password,walletFile.getScrypt().getN());
password=null;
}
 else {
acct.key=Helper.toHexString(account.serializePrivateKey());
}
acct.address=Address.addressFromPubKey(account.serializePublicKey()).toBase58();
if (label == null || label.equals("String_Node_Str")) {
String uuidStr=UUID.randomUUID().toString();
label=uuidStr.substring(0,8);
}
if (saveAccountFlag) {
for (Account e : wallet.getAccounts()) {
if (e.address.equals(acct.address)) {
throw new SDKException(ErrorCode.ParamErr("String_Node_Str"));
}
}
if (wallet.getAccounts().size() == 0) {
acct.isDefault=true;
wallet.setDefaultAccountAddress(acct.address);
}
acct.label=label;
wallet.getAccounts().add(acct);
}
 else {
for (Identity e : wallet.getIdentities()) {
if (e.ontid.equals(Common.didont + acct.address)) {
return account;
}
}
Identity idt=new Identity();
idt.ontid=Common.didont + acct.address;
idt.label=label;
if (wallet.getIdentities().size() == 0) {
idt.isDefault=true;
wallet.setDefaultOntid(idt.ontid);
}
idt.controls=new ArrayList<Control>();
Control ctl=new Control(acct.key,"String_Node_Str");
idt.controls.add(ctl);
wallet.getIdentities().add(idt);
}
return account;
}

Fixed version (ground truth):
private com.github.ontio.account.Account createAccount(String label,String password,byte[] privateKey,boolean saveAccountFlag) throws Exception {
  com.github.ontio.account.Account account=new com.github.ontio.account.Account(privateKey,scheme);
  Account acct;
switch (scheme) {
case SHA256WITHECDSA:
    acct=new Account("String_Node_Str",new Object[]{Curve.P256.toString()},"String_Node_Str","String_Node_Str","String_Node_Str");
  break;
case SM3WITHSM2:
acct=new Account("String_Node_Str",new Object[]{Curve.SM2P256V1.toString()},"String_Node_Str","String_Node_Str","String_Node_Str");
break;
default :
throw new SDKException(ErrorCode.OtherError("String_Node_Str"));
}
if (password != null) {
acct.key=account.exportCtrEncryptedPrikey(password,walletFile.getScrypt().getN());
password=null;
}
 else {
acct.key=Helper.toHexString(account.serializePrivateKey());
}
acct.address=Address.addressFromPubKey(account.serializePublicKey()).toBase58();
if (label == null || label.equals("String_Node_Str")) {
String uuidStr=UUID.randomUUID().toString();
label=uuidStr.substring(0,8);
}
if (saveAccountFlag) {
for (Account e : walletInMem.getAccounts()) {
if (e.address.equals(acct.address)) {
throw new SDKException(ErrorCode.ParamErr("String_Node_Str"));
}
}
if (walletInMem.getAccounts().size() == 0) {
acct.isDefault=true;
walletInMem.setDefaultAccountAddress(acct.address);
}
acct.label=label;
walletInMem.getAccounts().add(acct);
}
 else {
for (Identity e : walletInMem.getIdentities()) {
if (e.ontid.equals(Common.didont + acct.address)) {
return account;
}
}
Identity idt=new Identity();
idt.ontid=Common.didont + acct.address;
idt.label=label;
if (walletInMem.getIdentities().size() == 0) {
idt.isDefault=true;
walletInMem.setDefaultOntid(idt.ontid);
}
idt.controls=new ArrayList<Control>();
Control ctl=new Control(acct.key,"String_Node_Str");
idt.controls.add(ctl);
walletInMem.getIdentities().add(idt);
}
return account;
}