From 8a4e83da96b1d1bef5a170babb1f0ee4ed4b3539 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Sun, 4 Dec 2022 23:18:10 +0000 Subject: [PATCH] prevent segfaults on no toplevel proto available --- src/screencast/screencast.c | 1 + src/screencast/wlr_screencast.c | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/src/screencast/screencast.c b/src/screencast/screencast.c index 62f41ff..188e235 100644 --- a/src/screencast/screencast.c +++ b/src/screencast/screencast.c @@ -526,6 +526,7 @@ int xdpw_screencast_init(struct xdpw_state *state) { state->screencast = (struct xdpw_screencast_context) { 0 }; state->screencast.state = state; + state->screencast.hyprland_toplevel_manager = NULL; int err; err = xdpw_pwr_context_create(state); diff --git a/src/screencast/wlr_screencast.c b/src/screencast/wlr_screencast.c index 9e8858b..d807739 100644 --- a/src/screencast/wlr_screencast.c +++ b/src/screencast/wlr_screencast.c @@ -601,6 +601,10 @@ struct xdpw_share xdpw_wlr_chooser(struct xdpw_screencast_context *ctx) { struct xdpw_share res2 = {out, coords[0], coords[1], coords[2], coords[3]}; return res2; } else if (strncmp(result, "window:", 7) == 0) { + if (ctx->hyprland_toplevel_manager == NULL) { + return res; + } + char *display_name = malloc(strlen(result) - 7); strncpy(display_name, result + 7, strlen(result) - 8); display_name[strlen(result) - 8] = 0;