SDL: wayland: Check that the data device supports the release method before calling it

From 9667aa18e6c29885d8cd45efc2cf8bcb97270d7d Mon Sep 17 00:00:00 2001
From: Frank Praznik <[EMAIL REDACTED]>
Date: Tue, 26 Sep 2023 11:22:01 -0400
Subject: [PATCH] wayland: Check that the data device supports the release
 method before calling it

---
 src/video/wayland/SDL_waylandevents.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/video/wayland/SDL_waylandevents.c b/src/video/wayland/SDL_waylandevents.c
index 8e244541ce22..203e6a41e648 100644
--- a/src/video/wayland/SDL_waylandevents.c
+++ b/src/video/wayland/SDL_waylandevents.c
@@ -2759,7 +2759,11 @@ void Wayland_display_destroy_input(SDL_VideoData *d)
             Wayland_data_offer_destroy(input->data_device->drag_offer);
         }
         if (input->data_device->data_device != NULL) {
-            wl_data_device_release(input->data_device->data_device);
+            if (wl_data_device_get_version(input->data_device->data_device) >= WL_DATA_DEVICE_RELEASE_SINCE_VERSION) {
+                wl_data_device_release(input->data_device->data_device);
+            } else {
+                wl_data_device_destroy(input->data_device->data_device);
+            }
         }
         SDL_free(input->data_device);
     }