diff options
author | Haamed Gheibi <haamed@google.com> | 2022-03-09 12:05:14 -0800 |
---|---|---|
committer | Weijie Wang <quic_weijiew@quicinc.com> | 2022-03-15 15:38:25 +0800 |
commit | 12bb6d3cbf05cea529a165917c7430af607056f2 (patch) | |
tree | ff322630f9716306236ca70ecae1f265ae2aa2c6 /tools/aapt2/format/binary/BinaryResourceParser.cpp | |
parent | a42412b7fc93a0eb852d8bf1a4d001f7df7f43b3 (diff) |
Merge SP2A.220305.013
Bug: 220074017
Change-Id: Idfdd94e902f656ac65a2a75dfdd199f6f85ba472
Diffstat (limited to 'tools/aapt2/format/binary/BinaryResourceParser.cpp')
-rw-r--r-- | tools/aapt2/format/binary/BinaryResourceParser.cpp | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/tools/aapt2/format/binary/BinaryResourceParser.cpp b/tools/aapt2/format/binary/BinaryResourceParser.cpp index 72eaa3561a02..a8845ef96bc3 100644 --- a/tools/aapt2/format/binary/BinaryResourceParser.cpp +++ b/tools/aapt2/format/binary/BinaryResourceParser.cpp @@ -120,6 +120,13 @@ bool BinaryResourceParser::Parse() { static_cast<int>(parser.chunk()->type))); } } + + if (!staged_entries_to_remove_.empty()) { + diag_->Error(DiagMessage(source_) << "didn't find " << staged_entries_to_remove_.size() + << " original staged resources"); + return false; + } + return true; } @@ -393,6 +400,12 @@ bool BinaryResourceParser::ParseType(const ResourceTablePackage* package, return false; } + if (const auto to_remove_it = staged_entries_to_remove_.find({name, res_id}); + to_remove_it != staged_entries_to_remove_.end()) { + staged_entries_to_remove_.erase(to_remove_it); + continue; + } + NewResourceBuilder res_builder(name); res_builder.SetValue(std::move(resource_value), config) .SetId(res_id, OnIdConflict::CREATE_ENTRY) @@ -533,9 +546,8 @@ bool BinaryResourceParser::ParseStagedAliases(const ResChunk_header* chunk) { // Since a the finalized resource entry is cloned and added to the resource table under the // staged resource id, remove the cloned resource entry from the table. if (!table_->RemoveResource(resource_name, staged_id)) { - diag_->Error(DiagMessage(source_) << "failed to find resource entry for staged " - << " resource ID " << staged_id); - return false; + // If we haven't seen this resource yet let's add a record to skip it when parsing. + staged_entries_to_remove_.insert({resource_name, staged_id}); } } return true; |