Program: 85585
Project: 85585
Buggy source:
public void checkAndRemove(boolean forceExpiredRemoval){
  check();
  lock.lock();
  try {
    Iterator<Masternode> it=vMasternodes.iterator();
    while (it.hasNext()) {
      Masternode mn=it.next();
      if (mn.activeState == Masternode.MASTERNODE_REMOVE || mn.activeState == Masternode.MASTERNODE_VIN_SPENT || (forceExpiredRemoval && mn.activeState == Masternode.MASTERNODE_EXPIRED) || mn.protocolVersion < params.masternodePayments.getMinMasternodePaymentsProto()) {
        log.info("String_Node_Str",mn.address.toString(),size() - 1);
        Iterator<Map.Entry<Sha256Hash,MasternodeBroadcast>> it3=mapSeenMasternodeBroadcast.entrySet().iterator();
        while (it3.hasNext()) {
          Map.Entry<Sha256Hash,MasternodeBroadcast> mb=it3.next();
          if (mb.getValue().vin == mn.vin) {
            params.masternodeSync.mapSeenSyncMNB.remove(mb.getKey());
            it3.remove();
          }
        }
        Iterator<Map.Entry<TransactionOutPoint,Long>> it2=mWeAskedForMasternodeListEntry.entrySet().iterator();
        while (it2.hasNext()) {
          Map.Entry<TransactionOutPoint,Long> e=it2.next();
          if (e.getKey() == mn.vin.getOutpoint()) {
            it2.remove();
          }
        }
        it.remove();
      }
 else {
      }
    }
    Iterator<Map.Entry<NetAddress,Long>> it1=mAskedUsForMasternodeList.entrySet().iterator();
    while (it1.hasNext()) {
      Map.Entry<NetAddress,Long> e=it1.next();
      if (e.getValue() < Utils.currentTimeSeconds()) {
        it.remove();
      }
 else {
      }
    }
    it1=mWeAskedForMasternodeList.entrySet().iterator();
    while (it1.hasNext()) {
      Map.Entry<NetAddress,Long> e=it1.next();
      if (e.getValue() < Utils.currentTimeSeconds()) {
        it.remove();
      }
 else {
      }
    }
    Iterator<Map.Entry<TransactionOutPoint,Long>> it2=mWeAskedForMasternodeListEntry.entrySet().iterator();
    while (it2.hasNext()) {
      Map.Entry<TransactionOutPoint,Long> e=it2.next();
      if (e.getValue() < Utils.currentTimeSeconds()) {
        it2.remove();
      }
 else {
      }
    }
    Iterator<Map.Entry<Sha256Hash,MasternodeBroadcast>> it3=mapSeenMasternodeBroadcast.entrySet().iterator();
    while (it3.hasNext()) {
      Map.Entry<Sha256Hash,MasternodeBroadcast> mb=it3.next();
      if (mb.getValue().lastPing.sigTime < Utils.currentTimeSeconds() - (Masternode.MASTERNODE_REMOVAL_SECONDS * 2)) {
        params.masternodeSync.mapSeenSyncMNB.remove(mb.getValue().getHash());
        it3.remove();
      }
 else {
      }
    }
    Iterator<Map.Entry<Sha256Hash,MasternodePing>> it4=mapSeenMasternodePing.entrySet().iterator();
    while (it4.hasNext()) {
      Map.Entry<Sha256Hash,MasternodePing> mp=it4.next();
      if (mp.getValue().sigTime < Utils.currentTimeSeconds() - (Masternode.MASTERNODE_REMOVAL_SECONDS * 2)) {
        it4.remove();
      }
 else {
      }
    }
  }
  finally {
    lock.unlock();
  }
}

Fixed version (ground truth):
public void checkAndRemove(boolean forceExpiredRemoval){
  check();
  lock.lock();
  try {
    Iterator<Masternode> it=vMasternodes.iterator();
    while (it.hasNext()) {
      Masternode mn=it.next();
      if (mn.activeState == Masternode.MASTERNODE_REMOVE || mn.activeState == Masternode.MASTERNODE_VIN_SPENT || (forceExpiredRemoval && mn.activeState == Masternode.MASTERNODE_EXPIRED) || mn.protocolVersion < params.masternodePayments.getMinMasternodePaymentsProto()) {
        log.info("String_Node_Str",mn.address.toString(),size() - 1);
        Iterator<Map.Entry<Sha256Hash,MasternodeBroadcast>> it3=mapSeenMasternodeBroadcast.entrySet().iterator();
        while (it3.hasNext()) {
          Map.Entry<Sha256Hash,MasternodeBroadcast> mb=it3.next();
          if (mb.getValue().vin == mn.vin) {
            params.masternodeSync.mapSeenSyncMNB.remove(mb.getKey());
            it3.remove();
          }
        }
        Iterator<Map.Entry<TransactionOutPoint,Long>> it2=mWeAskedForMasternodeListEntry.entrySet().iterator();
        while (it2.hasNext()) {
          Map.Entry<TransactionOutPoint,Long> e=it2.next();
          if (e.getKey() == mn.vin.getOutpoint()) {
            it2.remove();
          }
        }
        it.remove();
      }
 else {
      }
    }
    Iterator<Map.Entry<NetAddress,Long>> it1=mAskedUsForMasternodeList.entrySet().iterator();
    while (it1.hasNext()) {
      Map.Entry<NetAddress,Long> e=it1.next();
      if (e.getValue() < Utils.currentTimeSeconds()) {
        it1.remove();
      }
 else {
      }
    }
    it1=mWeAskedForMasternodeList.entrySet().iterator();
    while (it1.hasNext()) {
      Map.Entry<NetAddress,Long> e=it1.next();
      if (e.getValue() < Utils.currentTimeSeconds()) {
        it1.remove();
      }
 else {
      }
    }
    Iterator<Map.Entry<TransactionOutPoint,Long>> it2=mWeAskedForMasternodeListEntry.entrySet().iterator();
    while (it2.hasNext()) {
      Map.Entry<TransactionOutPoint,Long> e=it2.next();
      if (e.getValue() < Utils.currentTimeSeconds()) {
        it2.remove();
      }
 else {
      }
    }
    Iterator<Map.Entry<Sha256Hash,MasternodeBroadcast>> it3=mapSeenMasternodeBroadcast.entrySet().iterator();
    while (it3.hasNext()) {
      Map.Entry<Sha256Hash,MasternodeBroadcast> mb=it3.next();
      if (mb.getValue().lastPing.sigTime < Utils.currentTimeSeconds() - (Masternode.MASTERNODE_REMOVAL_SECONDS * 2)) {
        params.masternodeSync.mapSeenSyncMNB.remove(mb.getValue().getHash());
        it3.remove();
      }
 else {
      }
    }
    Iterator<Map.Entry<Sha256Hash,MasternodePing>> it4=mapSeenMasternodePing.entrySet().iterator();
    while (it4.hasNext()) {
      Map.Entry<Sha256Hash,MasternodePing> mp=it4.next();
      if (mp.getValue().sigTime < Utils.currentTimeSeconds() - (Masternode.MASTERNODE_REMOVAL_SECONDS * 2)) {
        it4.remove();
      }
 else {
      }
    }
  }
  finally {
    lock.unlock();
  }
}