Skip to content

Commit

Permalink
Make get_types_by_name_prefixes actually match prefixes
Browse files Browse the repository at this point in the history
Summary: This was matching the given string anywhere, so "out" would match layout. Fix that.

Reviewed By: beicy

Differential Revision: D50388848

fbshipit-source-id: edfc3718af8768dc13d6c4eb116d8590a7a60927
  • Loading branch information
wsanville authored and facebook-github-bot committed Oct 19, 2023
1 parent d797e98 commit 1775315
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion libredex/ApkResources.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2563,7 +2563,7 @@ std::unordered_set<uint32_t> ResourcesArscFile::get_types_by_name_prefixes(
const auto& type_name = all_types.at(i);
if (std::find_if(type_name_prefixes.begin(), type_name_prefixes.end(),
[&](const std::string& prefix) {
return type_name.find(prefix) != std::string::npos;
return type_name.find(prefix) == 0;
}) != type_name_prefixes.end()) {
type_ids.emplace((i + 1) << TYPE_INDEX_BIT_SHIFT);
}
Expand Down
2 changes: 1 addition & 1 deletion libredex/BundleResources.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1908,7 +1908,7 @@ std::unordered_set<uint32_t> ResourcesPbFile::get_types_by_name_prefixes(
const auto& type_name = pair.second;
if (std::find_if(type_name_prefixes.begin(), type_name_prefixes.end(),
[&](const std::string& prefix) {
return type_name.find(prefix) != std::string::npos;
return type_name.find(prefix) == 0;
}) != type_name_prefixes.end()) {
type_ids.emplace((pair.first) << TYPE_INDEX_BIT_SHIFT);
}
Expand Down

0 comments on commit 1775315

Please sign in to comment.