fastbootd: Fix transport ownership.
This change moves Transport ownership back out of FastBootDriver.
Callers of set_transport must ensure that the previous transport is
destroyed. In addition, deleting a transport now ensures that it is
closed.
Bug: 78793464
Test: fastboot, fuzzy_fastboot works
Change-Id: I8f9ed2f7d5b09fd0820b2677d087a027378f26db
diff --git a/fastboot/engine.cpp b/fastboot/engine.cpp
index 6a52b12..d80e986 100644
--- a/fastboot/engine.cpp
+++ b/fastboot/engine.cpp
@@ -88,7 +88,9 @@
}
void fb_reinit(Transport* transport) {
- fb->set_transport(transport);
+ if (Transport* old_transport = fb->set_transport(transport)) {
+ delete old_transport;
+ }
}
const std::string fb_get_error() {
@@ -392,6 +394,6 @@
}
fprintf(stderr, "OKAY\n");
- fb->set_transport(nullptr);
+ fb_reinit(nullptr);
return true;
}