Merge "adb: add a way to make the server intentionally leak."
am: 1ac7150590

Change-Id: I4765b5726985555c5c7b325da2b779c7f1687dc0
diff --git a/adb/client/main.cpp b/adb/client/main.cpp
index f28302b..e5666bc 100644
--- a/adb/client/main.cpp
+++ b/adb/client/main.cpp
@@ -75,6 +75,11 @@
     usb_cleanup();
 }
 
+static void intentionally_leak() {
+    void* p = ::operator new(1);
+    LOG(INFO) << "leaking pointer " << p;
+}
+
 int adb_server_main(int is_daemon, const std::string& socket_spec, int ack_reply_fd) {
 #if defined(_WIN32)
     // adb start-server starts us up with stdout and stderr hooked up to
@@ -98,6 +103,11 @@
     });
 #endif
 
+    char* leak = getenv("ADB_LEAK");
+    if (leak && strcmp(leak, "1") == 0) {
+        intentionally_leak();
+    }
+
     if (is_daemon) {
         close_stdin();
         setup_daemon_logging();