[lptools] partition was freed, thus name was zero-ed, leading to a partition with an empty name rather than expected dst name

This commit is contained in:
Pierre-Hugues Husson 2021-03-28 18:57:09 +02:00
parent 00d5b05ee9
commit d9140dbd8d

View File

@ -194,6 +194,10 @@ int main(int argc, char **argv) {
if(dstPartition == nullptr) { if(dstPartition == nullptr) {
dstPartition = builder->FindPartition(dst + ::android::base::GetProperty("ro.boot.slot_suffix", "")); dstPartition = builder->FindPartition(dst + ::android::base::GetProperty("ro.boot.slot_suffix", ""));
} }
std::string dstPartitionName = dst;
if(dstPartition != nullptr) {
dstPartitionName = dstPartition->name();
}
std::vector<std::unique_ptr<Extent>> originalExtents; std::vector<std::unique_ptr<Extent>> originalExtents;
const auto& extents = srcPartition->extents(); const auto& extents = srcPartition->extents();
@ -209,8 +213,8 @@ int main(int argc, char **argv) {
} }
} }
builder->RemovePartition(srcPartition->name()); builder->RemovePartition(srcPartition->name());
builder->RemovePartition(dstPartition->name()); builder->RemovePartition(dstPartitionName);
auto newDstPartition = builder->AddPartition(dstPartition->name(), group, 0); auto newDstPartition = builder->AddPartition(dstPartitionName, group, 0);
for(auto&& extent: originalExtents) { for(auto&& extent: originalExtents) {
newDstPartition->AddExtent(std::move(extent)); newDstPartition->AddExtent(std::move(extent));
} }