output: #fixed code
                                  private void checkIt() {
          int maxSize = 0;
          BlockHeaderChain longestChain = null;
          StringBuilder str = new StringBuilder("++++++++++++++++++++++++chain info:");
          for (BlockHeaderChain chain : chainList) {
              str.append("+++++++++++\nchain:start-" + chain.getHeaderDigestList().get(0).getHeight() + ", end-" + chain.getHeaderDigestList().get(chain.size() - 1).getHeight());
              int listSize = chain.size();
              if (maxSize < listSize) {
                  maxSize = listSize;
                  longestChain = chain;
              } else if (maxSize == listSize) {
                  HeaderDigest hd = chain.getLastHd();
                  HeaderDigest hd_long = longestChain.getLastHd();
                  if (hd.getTime() < hd_long.getTime()) {
                      longestChain = chain;
                  }
              }
          }
          if (tempIndex % 10 == 0) {
              BlockLog.info(str.toString());
              tempIndex++;
          }
          if (this.approvingChain != null && !this.approvingChain.getId().equals(longestChain.getId())) {
              BlockService blockService = NulsContext.getServiceBean(BlockService.class);
              for (int i=approvingChain.size()-1;i>=0;i--) {
                  HeaderDigest hd = approvingChain.getHeaderDigestList().get(i);
                  try {
                      blockService.rollbackBlock(hd.getHash());
                  } catch (NulsException e) {
                      Log.error(e);
                  }
              }
              for(int i=0;i<longestChain.getHeaderDigestList().size();i++){
                  HeaderDigest hd = longestChain.getHeaderDigestList().get(i);
                  blockService.approvalBlock(hd.getHash());
              }
          }
          this.approvingChain = longestChain;
          Set<String> rightHashSet = new HashSet<>();
          Set<String> removeHashSet = new HashSet<>();
          for (int i = chainList.size() - 1; i >= 0; i--) {
              BlockHeaderChain chain = chainList.get(i);
              if (chain.size() < (maxSize - 6)) {
                  removeHashSet.addAll(chain.getHashSet());
                  this.chainList.remove(chain);
              } else {
                  rightHashSet.addAll(chain.getHashSet());
              }
          }
  
          for (String hash : removeHashSet) {
              if (!rightHashSet.contains(hash)) {
                  confirmingBlockCacheManager.removeBlock(hash);
              }
          }
  
      }
input: #vulnerable code 
                                  private void checkIt() {
          int maxSize = 0;
          BlockHeaderChain longestChain = null;
          StringBuilder str = new StringBuilder("++++++++++++++++++++++++chain info:");
          for (BlockHeaderChain chain : chainList) {
              str.append("+++++++++++\nchain:start-" + chain.getHeaderDigestList().get(0).getHeight() + ", end-" + chain.getHeaderDigestList().get(chain.size() - 1).getHeight());
              int listSize = chain.size();
              if (maxSize < listSize) {
                  maxSize = listSize;
                  longestChain = chain;
              } else if (maxSize == listSize) {
                  HeaderDigest hd = chain.getLastHd();
                  HeaderDigest hd_long = longestChain.getLastHd();
                  if (hd.getTime() < hd_long.getTime()) {
                      longestChain = chain;
                  }
              }
          }
          if (tempIndex % 10 == 0) {
              BlockLog.info(str.toString());
              tempIndex++;
          }
          if (this.approvingChain != null || !this.approvingChain.getId().equals(longestChain.getId())) {
              BlockService blockService = NulsContext.getServiceBean(BlockService.class);
              for (int i=approvingChain.size()-1;i>=0;i--) {
                  HeaderDigest hd = approvingChain.getHeaderDigestList().get(i);
                  try {
                      blockService.rollbackBlock(hd.getHash());
                  } catch (NulsException e) {
                      Log.error(e);
                  }
              }
              for(int i=0;i<longestChain.getHeaderDigestList().size();i++){
                  HeaderDigest hd = longestChain.getHeaderDigestList().get(i);
                  blockService.approvalBlock(hd.getHash());
              }
          }
          this.approvingChain = longestChain;
          Set<String> rightHashSet = new HashSet<>();
          Set<String> removeHashSet = new HashSet<>();
          for (int i = chainList.size() - 1; i >= 0; i--) {
              BlockHeaderChain chain = chainList.get(i);
              if (chain.size() < (maxSize - 6)) {
                  removeHashSet.addAll(chain.getHashSet());
                  this.chainList.remove(chain);
              } else {
                  rightHashSet.addAll(chain.getHashSet());
              }
          }
  
          for (String hash : removeHashSet) {
              if (!rightHashSet.contains(hash)) {
                  confirmingBlockCacheManager.removeBlock(hash);
              }
          }
  
      } 
                              #location 33 
                              #vulnerability type NULL_DEREFERENCE