Fix a potential memory leak
Bug: 65648324
Test: Built without seeing the warnings
Change-Id: I934509c78482af9ef7dc447c807f6450484b4b38
(cherry picked from commit f26cf6d52095a63f822ffc02d3b263543bdec0d9)
diff --git a/adb/services.cpp b/adb/services.cpp
index 3780747..cc840b8 100644
--- a/adb/services.cpp
+++ b/adb/services.cpp
@@ -481,11 +481,17 @@
return nullptr;
}
- int fd = create_service_thread(wait_for_state, sinfo.release());
+ int fd = create_service_thread(wait_for_state, sinfo.get());
+ if (fd != -1) {
+ sinfo.release();
+ }
return create_local_socket(fd);
} else if (!strncmp(name, "connect:", 8)) {
char* host = strdup(name + 8);
int fd = create_service_thread(connect_service, host);
+ if (fd == -1) {
+ free(host);
+ }
return create_local_socket(fd);
}
return NULL;