Revert "Remove unnecessary check from wlr_screencast.c" (#54)

* Revert "Remove unnecessary check from wlr_screencast.c"

This reverts commit cc59abb124.
Fixes emersion/xdg-desktop-portal-wlr#50

* Clarify why the check in wlr_screencast is needed
This commit is contained in:
Manuel Romei 2020-09-11 16:38:04 +02:00 committed by GitHub
parent 61db8968f9
commit 25e7719d18
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 3 deletions

View File

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