Marc Mutz
authored
The old code used indices to detect when it fell off the
end of m_chunks and needed to allocate a new chunk, but
this was opaque to Coverity, which saw the potential for
m_lastAllocatedChunk == nullptr at the end of the function,
and thus reported a nullptr deref there.
Fix by moving the scanning of m_chunks into a new method,
scan(), which more clearly communicates that it never
returns nullptr, not least because it returns by reference
instead of pointer.
Coverity-Id: 154279
Change-Id: I0cfe8fd819bbfc5b03a98b5e9354c0e98a521d34
Reviewed-by:
Paul Lemire <paul.lemire@kdab.com>