From 06d3e8fec7e2b29f99d755bee849023d88957953 Mon Sep 17 00:00:00 2001 From: Adam Lesinski Date: Thu, 5 Jan 2017 17:03:55 -0800 Subject: libandroidfw: Revert null check in ApplyStyle The out parameter `out_indices` is expected to be non-null and so the extra null check adds a cost to performance and opens the door to misusing the API by not supplying `out_indices`. Test: make libandroidfw_tests Change-Id: Ie66fd837c5e24ec2838156e7b67f54c15cd27933 --- libs/androidfw/AttributeResolution.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'libs/androidfw/AttributeResolution.cpp') diff --git a/libs/androidfw/AttributeResolution.cpp b/libs/androidfw/AttributeResolution.cpp index f5aef05e8842..d433b90f14f0 100644 --- a/libs/androidfw/AttributeResolution.cpp +++ b/libs/androidfw/AttributeResolution.cpp @@ -418,8 +418,10 @@ void ApplyStyle(ResTable::Theme* theme, ResXMLParser* xml_parser, uint32_t def_s out_values[STYLE_CHANGING_CONFIGURATIONS] = type_set_flags; out_values[STYLE_DENSITY] = config.density; - if (out_indices != nullptr && value.dataType != Res_value::TYPE_NULL) { + if (value.dataType != Res_value::TYPE_NULL) { indices_idx++; + + // out_indices must NOT be nullptr. out_indices[indices_idx] = ii; } @@ -428,9 +430,8 @@ void ApplyStyle(ResTable::Theme* theme, ResXMLParser* xml_parser, uint32_t def_s res.unlock(); - if (out_indices != nullptr) { - out_indices[0] = indices_idx; - } + // out_indices must NOT be nullptr. + out_indices[0] = indices_idx; } bool RetrieveAttributes(const ResTable* res, ResXMLParser* xml_parser, -- cgit v1.2.3-59-g8ed1b