From 8d24bb8dfc6bfc4b1d5c9952fd74c2b96378264e Mon Sep 17 00:00:00 2001 From: Ethan Lee Date: Thu, 11 Jul 2024 14:45:46 -0400 Subject: [PATCH] video: Added parameter checks to SDL_Vulkan_GetPresentationSupport --- src/video/SDL_video.c | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c index 9e7026cb3..be4e42f38 100644 --- a/src/video/SDL_video.c +++ b/src/video/SDL_video.c @@ -5530,18 +5530,30 @@ SDL_bool SDL_Vulkan_GetPresentationSupport(VkInstance instance, VkPhysicalDevice physicalDevice, Uint32 queueFamilyIndex) { - if (_this && instance && physicalDevice) { - if (_this->Vulkan_GetPresentationSupport) { - return _this->Vulkan_GetPresentationSupport(_this, instance, physicalDevice, queueFamilyIndex); - } - - /* If the backend does not have this function then it does not have a - * WSI function to query it; in other words it's not necessary to check - * as it is always supported. - */ - return SDL_TRUE; + if (!_this) { + SDL_UninitializedVideo(); + return SDL_FALSE; } - return SDL_FALSE; + + if (!instance) { + SDL_InvalidParamError("instance"); + return SDL_FALSE; + } + + if (!physicalDevice) { + SDL_InvalidParamError("physicalDevice"); + return SDL_FALSE; + } + + if (_this->Vulkan_GetPresentationSupport) { + return _this->Vulkan_GetPresentationSupport(_this, instance, physicalDevice, queueFamilyIndex); + } + + /* If the backend does not have this function then it does not have a + * WSI function to query it; in other words it's not necessary to check + * as it is always supported. + */ + return SDL_TRUE; } SDL_MetalView SDL_Metal_CreateView(SDL_Window *window)