prevent segfaults on no toplevel proto available

This commit is contained in:
vaxerski 2022-12-04 23:18:10 +00:00
parent 3c850a0336
commit 8a4e83da96
2 changed files with 5 additions and 0 deletions

View file

@ -526,6 +526,7 @@ int xdpw_screencast_init(struct xdpw_state *state) {
state->screencast = (struct xdpw_screencast_context) { 0 }; state->screencast = (struct xdpw_screencast_context) { 0 };
state->screencast.state = state; state->screencast.state = state;
state->screencast.hyprland_toplevel_manager = NULL;
int err; int err;
err = xdpw_pwr_context_create(state); err = xdpw_pwr_context_create(state);

View file

@ -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]}; struct xdpw_share res2 = {out, coords[0], coords[1], coords[2], coords[3]};
return res2; return res2;
} else if (strncmp(result, "window:", 7) == 0) { } else if (strncmp(result, "window:", 7) == 0) {
if (ctx->hyprland_toplevel_manager == NULL) {
return res;
}
char *display_name = malloc(strlen(result) - 7); char *display_name = malloc(strlen(result) - 7);
strncpy(display_name, result + 7, strlen(result) - 8); strncpy(display_name, result + 7, strlen(result) - 8);
display_name[strlen(result) - 8] = 0; display_name[strlen(result) - 8] = 0;