From 1245e9c353c3f42a77cc70e5d8615af459ebd1ee Mon Sep 17 00:00:00 2001 From: columbarius Date: Tue, 4 Aug 2020 17:32:43 +0200 Subject: [PATCH] munmap simple_frame.data only if needed in wlr_screencast.c --- src/screencast/wlr_screencast.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/screencast/wlr_screencast.c b/src/screencast/wlr_screencast.c index 915d62d..4fdcd04 100644 --- a/src/screencast/wlr_screencast.c +++ b/src/screencast/wlr_screencast.c @@ -105,10 +105,12 @@ static void wlr_frame_buffer(void *data, struct zwlr_screencopy_frame_v1 *frame, logprint(TRACE, "wlroots: buffer event handler"); cast->wlr_frame = frame; - if (cast->simple_frame.buffer == NULL || cast->simple_frame.width != width || cast->simple_frame.height != height || cast->simple_frame.stride != stride || cast->simple_frame.format != format) { + if (cast->simple_frame.buffer == NULL || cast->simple_frame.data == NULL || cast->simple_frame.width != width || cast->simple_frame.height != height || cast->simple_frame.stride != stride || cast->simple_frame.format != format) { logprint(TRACE, "wlroots: buffer properties changed"); - munmap(cast->simple_frame.data, cast->simple_frame.size); - cast->simple_frame.data = NULL; + if (cast->simple_frame.data != NULL) { + munmap(cast->simple_frame.data, cast->simple_frame.size); + cast->simple_frame.data = NULL; + } cast->simple_frame.width = width; cast->simple_frame.height = height; cast->simple_frame.stride = stride;