From 7121a0dc5310182cc1b003e40d36bd81bc1f9471 Mon Sep 17 00:00:00 2001 From: Romain Vimont Date: Sat, 1 Jan 2022 19:47:47 +0100 Subject: [PATCH] Destroy acksync immediately on error If AOA or HID keyboard may not be initialized for some reason, acksync is useless. --- app/src/scrcpy.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/src/scrcpy.c b/app/src/scrcpy.c index 52799da4..6b8074e9 100644 --- a/app/src/scrcpy.c +++ b/app/src/scrcpy.c @@ -454,25 +454,27 @@ scrcpy(struct scrcpy_options *options) { goto end; } - acksync = &s->acksync; - ok = sc_aoa_init(&s->aoa, serial, acksync); if (!ok) { + sc_acksync_destroy(&s->acksync); goto aoa_hid_end; } if (!sc_hid_keyboard_init(&s->keyboard_hid, &s->aoa)) { + sc_acksync_destroy(&s->acksync); sc_aoa_destroy(&s->aoa); goto aoa_hid_end; } if (!sc_aoa_start(&s->aoa)) { + sc_acksync_destroy(&s->acksync); sc_hid_keyboard_destroy(&s->keyboard_hid); sc_aoa_destroy(&s->aoa); goto aoa_hid_end; } kp = &s->keyboard_hid.key_processor; + acksync = &s->acksync; aoa_hid_initialized = true;