From 3c1405719ca4f75d1324ef2edf086d3a7dbccc9a Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Sat, 11 Nov 2023 11:33:51 +1100 Subject: [PATCH] [client] wayland: fix use after free bugs --- client/displayservers/Wayland/clipboard.c | 1 + client/displayservers/Wayland/presentation.c | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/client/displayservers/Wayland/clipboard.c b/client/displayservers/Wayland/clipboard.c index 7c84d223..08d2c7f2 100644 --- a/client/displayservers/Wayland/clipboard.c +++ b/client/displayservers/Wayland/clipboard.c @@ -475,6 +475,7 @@ void waylandCBRequest(LG_ClipboardData type) close(data->fd); free(data->buf); free(data); + return; } wlCb.currentRead = data; diff --git a/client/displayservers/Wayland/presentation.c b/client/displayservers/Wayland/presentation.c index 8bb235e3..c966beae 100644 --- a/client/displayservers/Wayland/presentation.c +++ b/client/displayservers/Wayland/presentation.c @@ -109,10 +109,17 @@ void waylandPresentationFrame(void) return; struct FrameData * data = malloc(sizeof(*data)); + if (!data) + { + DEBUG_ERROR("out of memory"); + return; + } + if (clock_gettime(wlWm.clkId, &data->sent)) { DEBUG_ERROR("clock_gettime failed: %s\n", strerror(errno)); free(data); + return; } struct wp_presentation_feedback * feedback = wp_presentation_feedback(wlWm.presentation, wlWm.surface);