munmap simple_frame.data only if needed in wlr_screencast.c

This commit is contained in:
columbarius 2020-08-04 17:32:43 +02:00 committed by Simon Ser
parent 4c20660f74
commit 1245e9c353
1 changed files with 5 additions and 3 deletions

View File

@ -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;