From aa34d63171c86a23942d575ac62410a0f8765a4d Mon Sep 17 00:00:00 2001 From: Romain Vimont Date: Wed, 3 Apr 2024 08:57:18 +0200 Subject: [PATCH] Fix segfault on close with --no-video Do not call sc_screen_hide_window() if screen is not initialized. To reproduce: scrcpy --no-video --record=file.mp4 This only segfaults in debug mode since commit fd0f432e877153d83ed435474fb7b04e41de4269. --- app/src/scrcpy.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app/src/scrcpy.c b/app/src/scrcpy.c index f43af35e..537562f4 100644 --- a/app/src/scrcpy.c +++ b/app/src/scrcpy.c @@ -805,9 +805,12 @@ scrcpy(struct scrcpy_options *options) { ret = event_loop(s); LOGD("quit..."); - // Close the window immediately on closing, because screen_destroy() may - // only be called once the video demuxer thread is joined (it may take time) - sc_screen_hide_window(&s->screen); + if (options->video_playback) { + // Close the window immediately on closing, because screen_destroy() + // may only be called once the video demuxer thread is joined (it may + // take time) + sc_screen_hide_window(&s->screen); + } end: if (timeout_started) {