Program: 85929
Project: 85929
Buggy source:
private void readConfidence(Transaction tx,Protos.TransactionConfidence confidenceProto,TransactionConfidence confidence){
  if (!confidenceProto.hasType()) {
    log.warn("String_Node_Str",tx.getHashAsString());
    return;
  }
  ConfidenceType confidenceType=TransactionConfidence.ConfidenceType.valueOf(confidenceProto.getType().getNumber());
  confidence.setConfidenceType(confidenceType);
  if (confidenceProto.hasAppearedAtHeight()) {
    if (confidence.getConfidenceType() != ConfidenceType.BUILDING) {
      log.warn("String_Node_Str",tx.getHashAsString());
      return;
    }
    confidence.setAppearedAtChainHeight(confidenceProto.getAppearedAtHeight());
  }
  if (confidenceProto.hasDepth()) {
    if (confidence.getConfidenceType() != ConfidenceType.BUILDING) {
      log.warn("String_Node_Str",tx.getHashAsString());
      return;
    }
    confidence.setDepthInBlocks(confidenceProto.getDepth());
  }
 else {
    if (chainHeight != 0) {
      confidence.setDepthInBlocks(chainHeight - confidence.getAppearedAtChainHeight());
    }
  }
  if (confidenceProto.hasWorkDone()) {
    if (confidence.getConfidenceType() != ConfidenceType.BUILDING) {
      log.warn("String_Node_Str",tx.getHashAsString());
      return;
    }
    confidence.setWorkDone(BigInteger.valueOf(confidenceProto.getWorkDone()));
  }
  if (confidenceProto.hasOverridingTransaction()) {
    if (confidence.getConfidenceType() != ConfidenceType.DEAD) {
      log.warn("String_Node_Str",tx.getHashAsString());
      return;
    }
    Transaction overridingTransaction=txMap.get(confidenceProto.getOverridingTransaction());
    if (overridingTransaction == null) {
      log.warn("String_Node_Str",tx.getHashAsString());
      return;
    }
    confidence.setOverridingTransaction(overridingTransaction);
  }
  for (  Protos.PeerAddress proto : confidenceProto.getBroadcastByList()) {
    InetAddress ip;
    try {
      ip=InetAddress.getByAddress(proto.getIpAddress().toByteArray());
    }
 catch (    UnknownHostException e) {
      throw new RuntimeException(e);
    }
    int port=proto.getPort();
    PeerAddress address=new PeerAddress(ip,port);
    address.setServices(BigInteger.valueOf(proto.getServices()));
    confidence.markBroadcastBy(address);
  }
}

Fixed version (ground truth):
private void readConfidence(Transaction tx,Protos.TransactionConfidence confidenceProto,TransactionConfidence confidence){
  if (!confidenceProto.hasType()) {
    log.warn("String_Node_Str",tx.getHashAsString());
    return;
  }
  ConfidenceType confidenceType=TransactionConfidence.ConfidenceType.valueOf(confidenceProto.getType().getNumber());
  confidence.setConfidenceType(confidenceType);
  if (confidenceProto.hasAppearedAtHeight()) {
    if (confidence.getConfidenceType() != ConfidenceType.BUILDING) {
      log.warn("String_Node_Str",tx.getHashAsString());
      return;
    }
    confidence.setAppearedAtChainHeight(confidenceProto.getAppearedAtHeight());
  }
  if (confidenceProto.hasDepth()) {
    if (confidence.getConfidenceType() != ConfidenceType.BUILDING) {
      log.warn("String_Node_Str",tx.getHashAsString());
      return;
    }
    confidence.setDepthInBlocks(confidenceProto.getDepth());
  }
 else {
    if (chainHeight != 0) {
      confidence.setDepthInBlocks(chainHeight - confidence.getAppearedAtChainHeight() + 1);
    }
  }
  if (confidenceProto.hasWorkDone()) {
    if (confidence.getConfidenceType() != ConfidenceType.BUILDING) {
      log.warn("String_Node_Str",tx.getHashAsString());
      return;
    }
    confidence.setWorkDone(BigInteger.valueOf(confidenceProto.getWorkDone()));
  }
  if (confidenceProto.hasOverridingTransaction()) {
    if (confidence.getConfidenceType() != ConfidenceType.DEAD) {
      log.warn("String_Node_Str",tx.getHashAsString());
      return;
    }
    Transaction overridingTransaction=txMap.get(confidenceProto.getOverridingTransaction());
    if (overridingTransaction == null) {
      log.warn("String_Node_Str",tx.getHashAsString());
      return;
    }
    confidence.setOverridingTransaction(overridingTransaction);
  }
  for (  Protos.PeerAddress proto : confidenceProto.getBroadcastByList()) {
    InetAddress ip;
    try {
      ip=InetAddress.getByAddress(proto.getIpAddress().toByteArray());
    }
 catch (    UnknownHostException e) {
      throw new RuntimeException(e);
    }
    int port=proto.getPort();
    PeerAddress address=new PeerAddress(ip,port);
    address.setServices(BigInteger.valueOf(proto.getServices()));
    confidence.markBroadcastBy(address);
  }
}