user101040: This function here gives a pointer to a block, and return the succesor block of that pointer.
    /** Find the successor of a block in this chain, or nullptr if the given index is not found or is the tip. */
    CBlockIndex* Next(const CBlockIndex* pindex) const
    {
        if (Contains(pindex))
            return (*this)[pindex->nHeight + 1];
        else
            return nullptr;
    }

If the given block is containing in the chain, it attempt to return the successor. So if the Chain.Tip() is given, it tries to reach the successor while there is no successor of the tip block. Isn't it better to check if nHeight of the given block is less than the Chain.Tip().nHeight - 1 or not?

user5406: That would not guarantee that the currently inspected block has a successor. While eventually the network converges on a single best chain, the network does temporarily fork occasionally, when two miners find a block at the same height. If a node were on the chaintip that is being reorged out there could be a block with a greater height, while it is not the successor of the node's current best block. Insofar, we must handle blocks not having successors anyway, so I assume that the nullptr is handled benignly somewhere in the surrounding code (I haven't checked, though).

101040: <p>This function <a href="https://github.com/bitcoin/bitcoin/blob/master/src/chain.h#L467" rel="nofollow noreferrer">here</a> gives a pointer to a block, and return the succesor block of that pointer.</p>
<pre><code>    /** Find the successor of a block in this chain, or nullptr if the given index is not found or is the tip. */
    CBlockIndex* Next(const CBlockIndex* pindex) const
    {
        if (Contains(pindex))
            return (*this)[pindex-&gt;nHeight + 1];
        else
            return nullptr;
    }
</code></pre>
<p>If the given block is containing in the chain, it attempt to return the successor. So if the <code>Chain.Tip()</code> is given, it tries to reach the successor while there is no successor of the tip block. Isn't it better to check if <code>nHeight</code> of the given block is less than the <code>Chain.Tip().nHeight - 1</code> or not?</p>
 5406: <p>That would not guarantee that the currently inspected block has a successor. While eventually the network converges on a single best chain, the network does temporarily fork occasionally, when two miners find a block at the same height. If a node were on the chaintip that is being reorged out there could be a block with a greater height, while it is not the successor of the node's current best block. Insofar, we must handle blocks not having successors anyway, so I assume that the <code>nullptr</code> is handled benignly somewhere in the surrounding code (I haven't checked, though).</p>
