Skip to content

Commit f583ff6

Browse files
Treehugger RobotGerrit Code Review
authored andcommitted
Merge "Fix a potential memory leak"
2 parents 1a955fa + f26cf6d commit f583ff6

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)