Program: 63517
Project: 63517
Buggy source:
@Override public boolean changePassword(CharSequence oldPassword,CharSequence newPassword){
  SQLiteDatabase readDb=this.mDb.getReadableDatabase();
  HashMap<String,String> addressesPrivKeyHashMap=new HashMap<String,String>();
  String sql="String_Node_Str";
  Cursor c=readDb.rawQuery(sql,null);
  while (c.moveToNext()) {
    addressesPrivKeyHashMap.put(c.getString(0),c.getString(1));
  }
  c.close();
  String hdmEncryptPassword=null;
  sql="String_Node_Str";
  c=readDb.rawQuery(sql,null);
  if (c.moveToNext()) {
    hdmEncryptPassword=c.getString(0);
  }
  c.close();
  HashMap<Integer,String> encryptSeedHashMap=new HashMap<Integer,String>();
  HashMap<Integer,String> encryptHDSeedHashMap=new HashMap<Integer,String>();
  HashMap<Integer,String> singularModeBackupHashMap=new HashMap<Integer,String>();
  sql="String_Node_Str";
  c=readDb.rawQuery(sql,null);
  while (c.moveToNext()) {
    Integer hdSeedId=c.getInt(0);
    String encryptSeed=c.getString(1);
    if (!c.isNull(2)) {
      String encryptHDSeed=c.getString(2);
      encryptHDSeedHashMap.put(hdSeedId,encryptHDSeed);
    }
    if (!c.isNull(3)) {
      String singularModeBackup=c.getString(3);
      singularModeBackupHashMap.put(hdSeedId,singularModeBackup);
    }
    encryptSeedHashMap.put(hdSeedId,encryptSeed);
  }
  c.close();
  HashMap<Integer,String> hdEncryptSeedHashMap=new HashMap<Integer,String>();
  HashMap<Integer,String> hdEncryptHDSeedHashMap=new HashMap<Integer,String>();
  c=readDb.rawQuery("String_Node_Str",null);
  while (c.moveToNext()) {
    int idColumn=c.getColumnIndex(AbstractDb.HDAccountColumns.HD_ACCOUNT_ID);
    Integer hdAccountId=0;
    if (idColumn != -1) {
      hdAccountId=c.getInt(idColumn);
    }
    idColumn=c.getColumnIndex(AbstractDb.HDAccountColumns.ENCRYPT_SEED);
    if (idColumn != -1) {
      String encryptSeed=c.getString(idColumn);
      hdEncryptSeedHashMap.put(hdAccountId,encryptSeed);
    }
    idColumn=c.getColumnIndex(AbstractDb.HDAccountColumns.ENCRYPT_MNMONIC_SEED);
    if (idColumn != -1) {
      String encryptHDSeed=c.getString(idColumn);
      hdEncryptHDSeedHashMap.put(hdAccountId,encryptHDSeed);
    }
  }
  c.close();
  PasswordSeed passwordSeed=null;
  sql="String_Node_Str";
  c=readDb.rawQuery(sql,null);
  if (c.moveToNext()) {
    passwordSeed=new PasswordSeed(c.getString(0));
  }
  c.close();
  for (  Map.Entry<String,String> kv : addressesPrivKeyHashMap.entrySet()) {
    kv.setValue(EncryptedData.changePwd(kv.getValue(),oldPassword,newPassword));
  }
  if (hdmEncryptPassword != null) {
    hdmEncryptPassword=EncryptedData.changePwd(hdmEncryptPassword,oldPassword,newPassword);
  }
  for (  Map.Entry<Integer,String> kv : encryptSeedHashMap.entrySet()) {
    kv.setValue(EncryptedData.changePwd(kv.getValue(),oldPassword,newPassword));
  }
  for (  Map.Entry<Integer,String> kv : encryptHDSeedHashMap.entrySet()) {
    kv.setValue(EncryptedData.changePwd(kv.getValue(),oldPassword,newPassword));
  }
  for (  Map.Entry<Integer,String> kv : hdEncryptSeedHashMap.entrySet()) {
    kv.setValue(EncryptedData.changePwd(kv.getValue(),oldPassword,newPassword));
  }
  for (  Map.Entry<Integer,String> kv : hdEncryptHDSeedHashMap.entrySet()) {
    kv.setValue(EncryptedData.changePwd(kv.getValue(),oldPassword,newPassword));
  }
  for (  Map.Entry<Integer,String> kv : singularModeBackupHashMap.entrySet()) {
    kv.setValue(EncryptedData.changePwd(kv.getValue(),oldPassword,newPassword));
  }
  if (passwordSeed != null) {
    boolean result=passwordSeed.changePassword(oldPassword,newPassword);
    if (!result) {
      return false;
    }
  }
  SQLiteDatabase writeDb=this.mDb.getWritableDatabase();
  writeDb.beginTransaction();
  ContentValues cv;
  for (  Map.Entry<String,String> kv : addressesPrivKeyHashMap.entrySet()) {
    cv=new ContentValues();
    cv.put(AbstractDb.AddressesColumns.ENCRYPT_PRIVATE_KEY,kv.getValue());
    writeDb.update(AbstractDb.Tables.Addresses,cv,"String_Node_Str",new String[]{kv.getKey()});
  }
  if (hdmEncryptPassword != null) {
    cv=new ContentValues();
    cv.put(AbstractDb.HDMBIdColumns.ENCRYPT_BITHER_PASSWORD,hdmEncryptPassword);
    writeDb.update(AbstractDb.Tables.HDM_BID,cv,null,null);
  }
  for (  Map.Entry<Integer,String> kv : encryptSeedHashMap.entrySet()) {
    cv=new ContentValues();
    cv.put(AbstractDb.HDSeedsColumns.ENCRYPT_SEED,kv.getValue());
    if (encryptHDSeedHashMap.containsKey(kv.getKey())) {
      cv.put(AbstractDb.HDSeedsColumns.ENCRYPT_MNMONIC_SEED,encryptHDSeedHashMap.get(kv.getKey()));
    }
    if (singularModeBackupHashMap.containsKey(kv.getKey())) {
      cv.put(AbstractDb.HDSeedsColumns.SINGULAR_MODE_BACKUP,singularModeBackupHashMap.get(kv.getKey()));
    }
    writeDb.update(AbstractDb.Tables.HDSEEDS,cv,"String_Node_Str",new String[]{kv.getKey().toString()});
  }
  for (  Map.Entry<Integer,String> kv : hdEncryptSeedHashMap.entrySet()) {
    cv=new ContentValues();
    cv.put(AbstractDb.HDAccountColumns.ENCRYPT_SEED,kv.getValue());
    if (hdEncryptHDSeedHashMap.containsKey(kv.getKey())) {
      cv.put(AbstractDb.HDAccountColumns.ENCRYPT_MNMONIC_SEED,hdEncryptHDSeedHashMap.get(kv.getValue()));
    }
    writeDb.update(AbstractDb.Tables.HD_ACCOUNT,cv,"String_Node_Str",new String[]{kv.getKey().toString()});
  }
  if (passwordSeed != null) {
    cv=new ContentValues();
    cv.put(AbstractDb.PasswordSeedColumns.PASSWORD_SEED,passwordSeed.toPasswordSeedString());
    writeDb.update(AbstractDb.Tables.PASSWORD_SEED,cv,null,null);
  }
  writeDb.setTransactionSuccessful();
  writeDb.endTransaction();
  return true;
}

Fixed version (ground truth):
@Override public boolean changePassword(CharSequence oldPassword,CharSequence newPassword){
  SQLiteDatabase readDb=this.mDb.getReadableDatabase();
  HashMap<String,String> addressesPrivKeyHashMap=new HashMap<String,String>();
  String sql="String_Node_Str";
  Cursor c=readDb.rawQuery(sql,null);
  while (c.moveToNext()) {
    addressesPrivKeyHashMap.put(c.getString(0),c.getString(1));
  }
  c.close();
  String hdmEncryptPassword=null;
  sql="String_Node_Str";
  c=readDb.rawQuery(sql,null);
  if (c.moveToNext()) {
    hdmEncryptPassword=c.getString(0);
  }
  c.close();
  HashMap<Integer,String> encryptSeedHashMap=new HashMap<Integer,String>();
  HashMap<Integer,String> encryptHDSeedHashMap=new HashMap<Integer,String>();
  HashMap<Integer,String> singularModeBackupHashMap=new HashMap<Integer,String>();
  sql="String_Node_Str";
  c=readDb.rawQuery(sql,null);
  while (c.moveToNext()) {
    Integer hdSeedId=c.getInt(0);
    String encryptSeed=c.getString(1);
    if (!c.isNull(2)) {
      String encryptHDSeed=c.getString(2);
      encryptHDSeedHashMap.put(hdSeedId,encryptHDSeed);
    }
    if (!c.isNull(3)) {
      String singularModeBackup=c.getString(3);
      singularModeBackupHashMap.put(hdSeedId,singularModeBackup);
    }
    encryptSeedHashMap.put(hdSeedId,encryptSeed);
  }
  c.close();
  HashMap<Integer,String> hdEncryptSeedHashMap=new HashMap<Integer,String>();
  HashMap<Integer,String> hdEncryptMnemonicSeedHashMap=new HashMap<Integer,String>();
  c=readDb.rawQuery("String_Node_Str",null);
  while (c.moveToNext()) {
    int idColumn=c.getColumnIndex(AbstractDb.HDAccountColumns.HD_ACCOUNT_ID);
    Integer hdAccountId=0;
    if (idColumn != -1) {
      hdAccountId=c.getInt(idColumn);
    }
    idColumn=c.getColumnIndex(AbstractDb.HDAccountColumns.ENCRYPT_SEED);
    if (idColumn != -1) {
      String encryptSeed=c.getString(idColumn);
      hdEncryptSeedHashMap.put(hdAccountId,encryptSeed);
    }
    idColumn=c.getColumnIndex(AbstractDb.HDAccountColumns.ENCRYPT_MNMONIC_SEED);
    if (idColumn != -1) {
      String encryptHDSeed=c.getString(idColumn);
      hdEncryptMnemonicSeedHashMap.put(hdAccountId,encryptHDSeed);
    }
  }
  c.close();
  PasswordSeed passwordSeed=null;
  sql="String_Node_Str";
  c=readDb.rawQuery(sql,null);
  if (c.moveToNext()) {
    passwordSeed=new PasswordSeed(c.getString(0));
  }
  c.close();
  for (  Map.Entry<String,String> kv : addressesPrivKeyHashMap.entrySet()) {
    kv.setValue(EncryptedData.changePwd(kv.getValue(),oldPassword,newPassword));
  }
  if (hdmEncryptPassword != null) {
    hdmEncryptPassword=EncryptedData.changePwd(hdmEncryptPassword,oldPassword,newPassword);
  }
  for (  Map.Entry<Integer,String> kv : encryptSeedHashMap.entrySet()) {
    kv.setValue(EncryptedData.changePwd(kv.getValue(),oldPassword,newPassword));
  }
  for (  Map.Entry<Integer,String> kv : encryptHDSeedHashMap.entrySet()) {
    kv.setValue(EncryptedData.changePwd(kv.getValue(),oldPassword,newPassword));
  }
  for (  Map.Entry<Integer,String> kv : hdEncryptSeedHashMap.entrySet()) {
    kv.setValue(EncryptedData.changePwd(kv.getValue(),oldPassword,newPassword));
  }
  for (  Map.Entry<Integer,String> kv : hdEncryptMnemonicSeedHashMap.entrySet()) {
    kv.setValue(EncryptedData.changePwd(kv.getValue(),oldPassword,newPassword));
  }
  for (  Map.Entry<Integer,String> kv : singularModeBackupHashMap.entrySet()) {
    kv.setValue(EncryptedData.changePwd(kv.getValue(),oldPassword,newPassword));
  }
  if (passwordSeed != null) {
    boolean result=passwordSeed.changePassword(oldPassword,newPassword);
    if (!result) {
      return false;
    }
  }
  SQLiteDatabase writeDb=this.mDb.getWritableDatabase();
  writeDb.beginTransaction();
  ContentValues cv;
  for (  Map.Entry<String,String> kv : addressesPrivKeyHashMap.entrySet()) {
    cv=new ContentValues();
    cv.put(AbstractDb.AddressesColumns.ENCRYPT_PRIVATE_KEY,kv.getValue());
    writeDb.update(AbstractDb.Tables.Addresses,cv,"String_Node_Str",new String[]{kv.getKey()});
  }
  if (hdmEncryptPassword != null) {
    cv=new ContentValues();
    cv.put(AbstractDb.HDMBIdColumns.ENCRYPT_BITHER_PASSWORD,hdmEncryptPassword);
    writeDb.update(AbstractDb.Tables.HDM_BID,cv,null,null);
  }
  for (  Map.Entry<Integer,String> kv : encryptSeedHashMap.entrySet()) {
    cv=new ContentValues();
    cv.put(AbstractDb.HDSeedsColumns.ENCRYPT_SEED,kv.getValue());
    if (encryptHDSeedHashMap.containsKey(kv.getKey())) {
      cv.put(AbstractDb.HDSeedsColumns.ENCRYPT_MNMONIC_SEED,encryptHDSeedHashMap.get(kv.getKey()));
    }
    if (singularModeBackupHashMap.containsKey(kv.getKey())) {
      cv.put(AbstractDb.HDSeedsColumns.SINGULAR_MODE_BACKUP,singularModeBackupHashMap.get(kv.getKey()));
    }
    writeDb.update(AbstractDb.Tables.HDSEEDS,cv,"String_Node_Str",new String[]{kv.getKey().toString()});
  }
  for (  Map.Entry<Integer,String> kv : hdEncryptSeedHashMap.entrySet()) {
    cv=new ContentValues();
    cv.put(AbstractDb.HDAccountColumns.ENCRYPT_SEED,kv.getValue());
    if (hdEncryptMnemonicSeedHashMap.containsKey(kv.getKey())) {
      cv.put(AbstractDb.HDAccountColumns.ENCRYPT_MNMONIC_SEED,hdEncryptMnemonicSeedHashMap.get(kv.getKey()));
    }
    writeDb.update(AbstractDb.Tables.HD_ACCOUNT,cv,"String_Node_Str",new String[]{kv.getKey().toString()});
  }
  if (passwordSeed != null) {
    cv=new ContentValues();
    cv.put(AbstractDb.PasswordSeedColumns.PASSWORD_SEED,passwordSeed.toPasswordSeedString());
    writeDb.update(AbstractDb.Tables.PASSWORD_SEED,cv,null,null);
  }
  writeDb.setTransactionSuccessful();
  writeDb.endTransaction();
  return true;
}