summaryrefslogtreecommitdiff
path: root/tools/aapt/ResourceTable.cpp
diff options
context:
space:
mode:
authorAdam Lesinski <adamlesinski@google.com>2016-08-15 18:45:00 -0700
committerAdam Lesinski <adamlesinski@google.com>2016-08-15 18:45:00 -0700
commit081d1b4cf602fdd7302b597e6bf902cb415bc3a8 (patch)
tree731e72ea0c123552ff69c8ffecb0d8a5de9d350b /tools/aapt/ResourceTable.cpp
parent2d280471669568d9e14cb7df679a51cf7f4d6c11 (diff)
AAPT: Handle gaps in resources when building splits
Due to public ID assignment, gaps in resource type and entry IDs can occur. This can lead to null pointer dereferencing if not careful. This happened in ResourceTable::getDensityVaryingResources() which is called when building Splits. Bug:30879690 Change-Id: I588e4dcd2e042fccfcb2e87967b5cbd0d23b4497
Diffstat (limited to 'tools/aapt/ResourceTable.cpp')
-rw-r--r--tools/aapt/ResourceTable.cpp27
1 files changed, 21 insertions, 6 deletions
diff --git a/tools/aapt/ResourceTable.cpp b/tools/aapt/ResourceTable.cpp
index 76c59dd57068..661409e3d4bc 100644
--- a/tools/aapt/ResourceTable.cpp
+++ b/tools/aapt/ResourceTable.cpp
@@ -4860,24 +4860,39 @@ void ResourceTable::getDensityVaryingResources(
const Vector<sp<Type> >& types = mOrderedPackages[p]->getOrderedTypes();
const size_t typeCount = types.size();
for (size_t t = 0; t < typeCount; t++) {
- const Vector<sp<ConfigList> >& configs = types[t]->getOrderedConfigs();
+ const sp<Type>& type = types[t];
+ if (type == NULL) {
+ continue;
+ }
+
+ const Vector<sp<ConfigList> >& configs = type->getOrderedConfigs();
const size_t configCount = configs.size();
for (size_t c = 0; c < configCount; c++) {
+ const sp<ConfigList>& configList = configs[c];
+ if (configList == NULL) {
+ continue;
+ }
+
const DefaultKeyedVector<ConfigDescription, sp<Entry> >& configEntries
- = configs[c]->getEntries();
+ = configList->getEntries();
const size_t configEntryCount = configEntries.size();
for (size_t ce = 0; ce < configEntryCount; ce++) {
+ const sp<Entry>& entry = configEntries.valueAt(ce);
+ if (entry == NULL) {
+ continue;
+ }
+
const ConfigDescription& config = configEntries.keyAt(ce);
if (AaptConfig::isDensityOnly(config)) {
// This configuration only varies with regards to density.
const Symbol symbol(
mOrderedPackages[p]->getName(),
- types[t]->getName(),
- configs[c]->getName(),
+ type->getName(),
+ configList->getName(),
getResId(mOrderedPackages[p], types[t],
- configs[c]->getEntryIndex()));
+ configList->getEntryIndex()));
+
- const sp<Entry>& entry = configEntries.valueAt(ce);
AaptUtil::appendValue(resources, symbol,
SymbolDefinition(symbol, config, entry->getPos()));
}