diff --git a/src/screencast/wlr_screencast.c b/src/screencast/wlr_screencast.c index cf4167f..3b324a9 100644 --- a/src/screencast/wlr_screencast.c +++ b/src/screencast/wlr_screencast.c @@ -20,9 +20,14 @@ #include "logger.h" static void wlr_frame_buffer_destroy(struct xdpw_screencast_instance *cast) { - munmap(cast->simple_frame.data, cast->simple_frame.size); - cast->simple_frame.data = NULL; - // wl_buffer_destroy won't work on NULL + // Even though this check may be deemed unnecessary, + // this has been found to cause SEGFAULTs, like this one: + // https://github.com/emersion/xdg-desktop-portal-wlr/issues/50 + if (cast->simple_frame.data != NULL) { + munmap(cast->simple_frame.data, cast->simple_frame.size); + cast->simple_frame.data = NULL; + } + if (cast->simple_frame.buffer != NULL) { wl_buffer_destroy(cast->simple_frame.buffer); cast->simple_frame.buffer = NULL;