From 87b69dc91ab37635dc0d3402fd1246dab3995a62 Mon Sep 17 00:00:00 2001 From: Ian Elliott Date: Tue, 5 Jan 2016 14:28:32 -0700 Subject: Swapchain: Change way p*Count is checked--make sure not bigger than should be. --- layers/swapchain.cpp | 9 ++++++--- layers/swapchain.h | 9 +++++---- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/layers/swapchain.cpp b/layers/swapchain.cpp index 7c19c272..3441c955 100644 --- a/layers/swapchain.cpp +++ b/layers/swapchain.cpp @@ -1001,11 +1001,12 @@ VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSurfaceFormats pSurfaceFormatCount) { // Compare the preliminary value of *pSurfaceFormatCount with the // value this time: - if (*pSurfaceFormatCount != pPhysicalDevice->surfaceFormatCount) { + if (*pSurfaceFormatCount > pPhysicalDevice->surfaceFormatCount) { LOG_ERROR_INVALID_COUNT(VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, physicalDevice, "pSurfaceFormatCount", "pSurfaceFormats", + *pSurfaceFormatCount, pPhysicalDevice->surfaceFormatCount); } else if (*pSurfaceFormatCount > 0) { @@ -1069,11 +1070,12 @@ VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSurfacePresent pPresentModeCount) { // Compare the preliminary value of *pPresentModeCount with the // value this time: - if (*pPresentModeCount != pPhysicalDevice->presentModeCount) { + if (*pPresentModeCount > pPhysicalDevice->presentModeCount) { LOG_ERROR_INVALID_COUNT(VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, physicalDevice, "pPresentModeCount", "pPresentModes", + *pPresentModeCount, pPhysicalDevice->presentModeCount); } else if (*pPresentModeCount > 0) { @@ -1579,11 +1581,12 @@ VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkGetSwapchainImagesKHR( pSwapchainImageCount) { // Compare the preliminary value of *pSwapchainImageCount with the // value this time: - if (*pSwapchainImageCount != pSwapchain->imageCount) { + if (*pSwapchainImageCount > pSwapchain->imageCount) { LOG_ERROR_INVALID_COUNT(VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, device, "pSwapchainImageCount", "pSwapchainImages", + *pSwapchainImageCount, pSwapchain->imageCount); } else if (*pSwapchainImageCount > 0) { diff --git a/layers/swapchain.h b/layers/swapchain.h index 27a4ab6f..d4b0f236 100644 --- a/layers/swapchain.h +++ b/layers/swapchain.h @@ -105,13 +105,14 @@ typedef enum _SWAPCHAIN_ERROR (uint64_t) (obj), 0, SWAPCHAIN_NULL_POINTER, LAYER_NAME, \ "%s() called with NULL pointer %s.", __FUNCTION__, (obj)) \ : VK_FALSE -#define LOG_ERROR_INVALID_COUNT(objType, type, obj, obj2, val) \ +#define LOG_ERROR_INVALID_COUNT(objType, type, obj, obj2, val, val2) \ (my_data) ? \ log_msg(my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, (objType), \ (uint64_t) (obj), 0, SWAPCHAIN_INVALID_COUNT, LAYER_NAME, \ - "%s() called with non-NULL %s, and with %s not matching " \ - "the value (%d) that was returned when %s was NULL.", \ - __FUNCTION__, (obj2), (obj), (val), (obj2)) \ + "%s() called with non-NULL %s, and with %s set to a " \ + "value (%d) that is greater than the value (%d) that " \ + "was returned when %s was NULL.", \ + __FUNCTION__, (obj2), (obj), (val), (val2), (obj2)) \ : VK_FALSE #define LOG_ERROR_WRONG_STYPE(objType, type, obj, val) \ (my_data) ? \ -- cgit v1.2.3