From d9140dbd8d5e4b8c70a6491b8d02bc8072a1b149 Mon Sep 17 00:00:00 2001 From: Pierre-Hugues Husson Date: Sun, 28 Mar 2021 18:57:09 +0200 Subject: [PATCH] [lptools] partition was freed, thus name was zero-ed, leading to a partition with an empty name rather than expected dst name --- cmds/lptools.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/cmds/lptools.cc b/cmds/lptools.cc index b5d8e87..bb62850 100644 --- a/cmds/lptools.cc +++ b/cmds/lptools.cc @@ -194,6 +194,10 @@ int main(int argc, char **argv) { if(dstPartition == nullptr) { dstPartition = builder->FindPartition(dst + ::android::base::GetProperty("ro.boot.slot_suffix", "")); } + std::string dstPartitionName = dst; + if(dstPartition != nullptr) { + dstPartitionName = dstPartition->name(); + } std::vector> originalExtents; const auto& extents = srcPartition->extents(); @@ -209,8 +213,8 @@ int main(int argc, char **argv) { } } builder->RemovePartition(srcPartition->name()); - builder->RemovePartition(dstPartition->name()); - auto newDstPartition = builder->AddPartition(dstPartition->name(), group, 0); + builder->RemovePartition(dstPartitionName); + auto newDstPartition = builder->AddPartition(dstPartitionName, group, 0); for(auto&& extent: originalExtents) { newDstPartition->AddExtent(std::move(extent)); }