SDL: wayland: Check the relative pointer handle before destroying (7d959)

From 7d9595b14fe1808eedeb69b7c58a4b90c187ce5b Mon Sep 17 00:00:00 2001
From: Frank Praznik <[EMAIL REDACTED]>
Date: Sun, 29 Oct 2023 14:12:38 -0400
Subject: [PATCH] wayland: Check the relative pointer handle before destroying

If the relative protocol is unsupported, this will always be null and the destroy function won't be called.

(cherry picked from commit 0e87b71d08c75af8c4b02808038825d3b16bf854)
(cherry picked from commit 19c3e125ba71e4667743316f606872cc39f25a81)
---
 src/video/wayland/SDL_waylandevents.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/video/wayland/SDL_waylandevents.c b/src/video/wayland/SDL_waylandevents.c
index 160185ffc11c..216ae5436c5e 100644
--- a/src/video/wayland/SDL_waylandevents.c
+++ b/src/video/wayland/SDL_waylandevents.c
@@ -2621,8 +2621,10 @@ int Wayland_input_unlock_pointer(struct SDL_WaylandInput *input)
         w->locked_pointer = NULL;
     }
 
-    zwp_relative_pointer_v1_destroy(input->relative_pointer);
-    input->relative_pointer = NULL;
+    if (input->relative_pointer) {
+        zwp_relative_pointer_v1_destroy(input->relative_pointer);
+        input->relative_pointer = NULL;
+    }
 
     d->relative_mouse_mode = 0;