Merge "fix use-after-free in adbd_auth" am: 8e3f9dc03d am: 0522e004bd

Original change: https://android-review.googlesource.com/c/platform/frameworks/native/+/1539159

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I6e087b228e84ace35c5b89acd8ef226a5c99a084
diff --git a/libs/adbd_auth/adbd_auth.cpp b/libs/adbd_auth/adbd_auth.cpp
index dae6eeb..15bd5c3 100644
--- a/libs/adbd_auth/adbd_auth.cpp
+++ b/libs/adbd_auth/adbd_auth.cpp
@@ -282,9 +282,8 @@
             LOG(FATAL) << "adbd_auth: unhandled packet type?";
         }
 
-        output_queue_.pop_front();
-
         ssize_t rc = writev(framework_fd_.get(), iovs, iovcnt);
+        output_queue_.pop_front();
         if (rc == -1 && errno != EAGAIN && errno != EWOULDBLOCK) {
             PLOG(ERROR) << "adbd_auth: failed to write to framework fd";
             ReplaceFrameworkFd(unique_fd());