https://github.com/bitcoin/bitcoin/blob/9ad6f14175c19b5d47267c3dd5840c14bad43c83/src/validation.cpp#L3711

If i'm following right the flow of the code, when we hit this lane `pindex` should be always equal to nullptr thus this check may be omitted
bool blocks_connected = false;
            do {
                
                
                ConnectTrace connectTrace; 
                if (pindexMostWork == nullptr) {
                    pindexMostWork = FindMostWorkChain();
                }
                
                if (pindexMostWork == nullptr || pindexMostWork == m_chain.Tip()) {
                    break;
                }
                bool fInvalidFound = false;
                std::shared_ptr<const CBlock> nullBlockPtr;
                if (!ActivateBestChainStep(state, chainparams, pindexMostWork, pblock && pblock->GetHash() == pindexMostWork->GetBlockHash() ? pblock : nullBlockPtr, fInvalidFound, connectTrace)) {
                    
                    return false;
                }
                blocks_connected = true;
                if (fInvalidFound) {
                    
                    pindexMostWork = nullptr;
                }
                pindexNewTip = m_chain.Tip();
                for (const PerBlockConnectTrace& trace : connectTrace.GetBlocksConnected()) {
                    assert(trace.pblock && trace.pindex);
                    GetMainSignals().BlockConnected(trace.pblock, trace.pindex);
                }
            } while (!m_chain.Tip() || (starting_tip && CBlockIndexWorkComparator()(m_chain.Tip(), starting_tip)));
            if (!blocks_connected) return true;