From 666b6fbba15dec2a29a40c11ddb3aa590eb9d1b0 Mon Sep 17 00:00:00 2001 From: Adam Lesinski Date: Thu, 21 Apr 2016 10:05:06 -0700 Subject: [PATCH] Fix order of operation issue with ResStringPool Due to ! taking precedence over bitwise &, the condition for checking non-null terminated string blocks is incorrect. Adds parentheses for the correct behavior. Bug:28288210 Change-Id: Ie31fa239e5f869e6bb28deb6ae190f41f1aa4d92 --- libs/androidfw/ResourceTypes.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/androidfw/ResourceTypes.cpp b/libs/androidfw/ResourceTypes.cpp index 15cb684ee08e9..c3dfb89180de6 100644 --- a/libs/androidfw/ResourceTypes.cpp +++ b/libs/androidfw/ResourceTypes.cpp @@ -562,7 +562,7 @@ status_t ResStringPool::setTo(const void* data, size_t size, bool copyData) if ((mHeader->flags&ResStringPool_header::UTF8_FLAG && ((uint8_t*)mStrings)[mStringPoolSize-1] != 0) || - (!mHeader->flags&ResStringPool_header::UTF8_FLAG && + (!(mHeader->flags&ResStringPool_header::UTF8_FLAG) && ((uint16_t*)mStrings)[mStringPoolSize-1] != 0)) { ALOGW("Bad string block: last string is not 0-terminated\n"); return (mError=BAD_TYPE);