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

View file

@ -20,9 +20,14 @@
#include "logger.h" #include "logger.h"
static void wlr_frame_buffer_destroy(struct xdpw_screencast_instance *cast) { static void wlr_frame_buffer_destroy(struct xdpw_screencast_instance *cast) {
// 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); munmap(cast->simple_frame.data, cast->simple_frame.size);
cast->simple_frame.data = NULL; cast->simple_frame.data = NULL;
// wl_buffer_destroy won't work on NULL }
if (cast->simple_frame.buffer != NULL) { if (cast->simple_frame.buffer != NULL) {
wl_buffer_destroy(cast->simple_frame.buffer); wl_buffer_destroy(cast->simple_frame.buffer);
cast->simple_frame.buffer = NULL; cast->simple_frame.buffer = NULL;