From fa4eaa63caae8eefa3ca6eba9830be747eb32cd0 Mon Sep 17 00:00:00 2001 From: George Burgess IV Date: Tue, 18 Jul 2017 16:28:28 -0700 Subject: [PATCH] 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 --- libs/hwui/font/CacheTexture.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libs/hwui/font/CacheTexture.cpp b/libs/hwui/font/CacheTexture.cpp index e2844ad0649a4..73beba9297c4e 100644 --- a/libs/hwui/font/CacheTexture.cpp +++ b/libs/hwui/font/CacheTexture.cpp @@ -91,6 +91,9 @@ CacheBlock* CacheBlock::removeBlock(CacheBlock* head, CacheBlock* blockToRemove) CacheBlock* prevBlock = blockToRemove->mPrev; 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; } else { newHead = nextBlock;