Skip to content

Commit f26cf6d

Browse files
committed
Fix a potential memory leak
Test: Built without seeing the warnings Change-Id: I934509c78482af9ef7dc447c807f6450484b4b38
1 parent 2c3a2a8 commit f26cf6d

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

adb/services.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -478,11 +478,17 @@ asocket* host_service_to_socket(const char* name, const char* serial) {
478478
return nullptr;
479479
}
480480

481-
int fd = create_service_thread(wait_for_state, sinfo.release());
481+
int fd = create_service_thread(wait_for_state, sinfo.get());
482+
if (fd != -1) {
483+
sinfo.release();
484+
}
482485
return create_local_socket(fd);
483486
} else if (!strncmp(name, "connect:", 8)) {
484487
char* host = strdup(name + 8);
485488
int fd = create_service_thread(connect_service, host);
489+
if (fd == -1) {
490+
free(host);
491+
}
486492
return create_local_socket(fd);
487493
}
488494
return NULL;

0 commit comments

Comments
 (0)