Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fa4eaa63 authored by George Burgess IV's avatar George Burgess IV
Browse files

Appease the static analyzer

Since the static analyzer assumes that
`head == blockToRemove && blockToRemove->prevBlock == nullptr` may be
true, it complains that we're deleting `head` and returning `head`
shortly afterward.

Assert (without assertions, since -DNDEBUG is passed) that this isn't
the case.

Bug: 27101951
Test: mma. Warning is gone.
Change-Id: I33e98eec7b293fcf0d8826f89c287a3b870758f2
parent 1ad8903b
Loading
Loading
Loading
Loading
+3 −0
Original line number Original line Diff line number Diff line
@@ -91,6 +91,9 @@ CacheBlock* CacheBlock::removeBlock(CacheBlock* head, CacheBlock* blockToRemove)
    CacheBlock* prevBlock = blockToRemove->mPrev;
    CacheBlock* prevBlock = blockToRemove->mPrev;


    if (prevBlock) {
    if (prevBlock) {
        // If this doesn't hold, we have a use-after-free below.
        LOG_ALWAYS_FATAL_IF(head == blockToRemove,
                "removeBlock: head should not have a previous block");
        prevBlock->mNext = nextBlock;
        prevBlock->mNext = nextBlock;
    } else {
    } else {
        newHead = nextBlock;
        newHead = nextBlock;