Guard data source being deleted before processing dataoffer receive event

Summary:
A data source can disappear at any moment, it's plausible a client could
have requested data whilst the client was alive and we are processing it
afterwards.

The accept and finish callback guard against the source being deleted,
but recieve did not.

BUG: 400311

Test Plan: Could still copy/paste as before

Reviewers: #kwin, romangg

Reviewed By: #kwin, romangg

Subscribers: kde-frameworks-devel

Tags: #frameworks

Differential Revision: https://phabricator.kde.org/D16431
This commit is contained in:
David Edmundson 2018-10-29 10:09:29 +00:00
parent 96967485ba
commit bd7acc0ee2

View file

@ -24,6 +24,8 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
#include <QStringList>
// Wayland
#include <wayland-server.h>
// system
#include <unistd.h>
namespace KWayland
{
@ -69,6 +71,10 @@ void DataOfferInterface::Private::receiveCallback(wl_client *client, wl_resource
void DataOfferInterface::Private::receive(const QString &mimeType, qint32 fd)
{
if (!source) {
close(fd);
return;
}
source->requestData(mimeType, fd);
}