Skip to content

Commit

Permalink
Prevent loading from resource pool if type is not a resolveable resou…
Browse files Browse the repository at this point in the history
…rce (#3187)

* perf: prefer the shifted resId vs expensive package calls

* fix: only lookup values if reference/value
  • Loading branch information
iBotPeaches committed Jul 21, 2023
1 parent 2610033 commit d4ec44d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,14 @@ public String getAttributeValue(int index) {
if (mAttrDecoder != null) {
try {
String stringBlockValue = valueRaw == -1 ? null : ResXmlEncoders.escapeXmlChars(mStringBlock.getString(valueRaw));
String resourceMapValue = mAttrDecoder.decodeFromResourceId(valueData);
String resourceMapValue = null;

// Ensure we only track down obfuscated values for reference/attribute type values. Otherwise we might
// spam lookups against resource table for invalid ids.
if (valueType == TypedValue.TYPE_REFERENCE || valueType == TypedValue.TYPE_DYNAMIC_REFERENCE ||
valueType == TypedValue.TYPE_ATTRIBUTE || valueType == TypedValue.TYPE_DYNAMIC_ATTRIBUTE) {
resourceMapValue = mAttrDecoder.decodeFromResourceId(valueData);
}
String value = stringBlockValue;

if (stringBlockValue != null && resourceMapValue != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,8 @@ public String decodeFromResourceId(int attrResId)
throws AndrolibException {

if (attrResId != 0) {
ResID resId = new ResID(attrResId);

try {
ResResSpec resResSpec = mResTable.getResSpec(resId);
ResResSpec resResSpec = mResTable.getResSpec(attrResId);
if (resResSpec != null) {
return resResSpec.getName();
}
Expand Down

0 comments on commit d4ec44d

Please sign in to comment.