From 632bd5697b6e699e8945a79642a11fd3ffdcc289 Mon Sep 17 00:00:00 2001 From: Romain Vimont Date: Wed, 17 Nov 2021 18:36:03 +0100 Subject: [PATCH] Add missing error handling If "adb get-serialno" fails, attempting to read from the uninitialized pipe is incorrect. --- app/src/adb.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/src/adb.c b/app/src/adb.c index 6251174e..4f50ee5f 100644 --- a/app/src/adb.c +++ b/app/src/adb.c @@ -239,6 +239,9 @@ adb_execute_for_output(const char *serial, const char *const adb_cmd[], const char *name) { sc_pipe pout; sc_pid pid = adb_execute_p(serial, adb_cmd, adb_cmd_len, NULL, &pout, NULL); + if (pid == SC_PROCESS_NONE) { + return -1; + } ssize_t r = sc_pipe_read_all(pout, buf, buf_len); sc_pipe_close(pout);