Change source to be a unique_ptr.
The current code keeps a pointer to a local variable which doesn't
work too well. Change this to a unique_ptr and allocate the source
object that will be used instead.
Test: All unit tests pass.
Test: fastboot -w flashall on a mokey which crashed without this change.
Change-Id: Ief5437374181e514928c45dd540b42898901a137
diff --git a/fastboot/task.cpp b/fastboot/task.cpp
index 4b2b9e3..25c5a6e 100644
--- a/fastboot/task.cpp
+++ b/fastboot/task.cpp
@@ -41,7 +41,7 @@
void FlashTask::Run() {
auto flash = [&](const std::string& partition) {
- if (should_flash_in_userspace(fp_->source, partition) && !is_userspace_fastboot() &&
+ if (should_flash_in_userspace(fp_->source.get(), partition) && !is_userspace_fastboot() &&
!fp_->force_flash) {
die("The partition you are trying to flash is dynamic, and "
"should be flashed via fastbootd. Please run:\n"
@@ -174,7 +174,7 @@
LOG(VERBOSE) << "Cannot optimize flashing super for all slots";
return nullptr;
}
- if (!CanOptimize(fp->source, tasks)) {
+ if (!CanOptimize(fp->source.get(), tasks)) {
return nullptr;
}