vk: Fix size return value handling in a couple plces
authorJason Ekstrand <jason.ekstrand@intel.com>
Sat, 5 Sep 2015 02:05:51 +0000 (19:05 -0700)
committerJason Ekstrand <jason.ekstrand@intel.com>
Sat, 5 Sep 2015 02:05:51 +0000 (19:05 -0700)
src/vulkan/anv_device.c
src/vulkan/anv_wsi_wayland.c
src/vulkan/anv_wsi_x11.c

index c1758de537cc6614e4f9a045fff8a6d49cba5773..cf93cd1a6ebcdf242a14c774e78a60f7db753cd7 100644 (file)
@@ -653,7 +653,7 @@ VkResult anv_GetGlobalExtensionProperties(
       return VK_SUCCESS;
    }
 
-   assert(*pCount <= ARRAY_SIZE(global_extensions));
+   assert(*pCount >= ARRAY_SIZE(global_extensions));
 
    *pCount = ARRAY_SIZE(global_extensions);
    memcpy(pProperties, global_extensions, sizeof(global_extensions));
@@ -679,7 +679,7 @@ VkResult anv_GetPhysicalDeviceExtensionProperties(
       return VK_SUCCESS;
    }
 
-   assert(*pCount < ARRAY_SIZE(device_extensions));
+   assert(*pCount >= ARRAY_SIZE(device_extensions));
 
    *pCount = ARRAY_SIZE(device_extensions);
    memcpy(pProperties, device_extensions, sizeof(device_extensions));
index e23f5933fe4c7d031321f00b2187b5bc2fe75b99..11f2dae97592c21fd95e3bdd350da8a61fb5e5f1 100644 (file)
@@ -327,9 +327,15 @@ wsi_wl_get_surface_info(struct anv_wsi_implementation *impl,
 
    switch (infoType) {
    case VK_SURFACE_INFO_TYPE_PROPERTIES_WSI: {
-      assert(*pDataSize >= sizeof(VkSurfacePropertiesWSI));
       VkSurfacePropertiesWSI *props = pData;
 
+      if (pData == NULL) {
+         *pDataSize = sizeof(*props);
+         return VK_SUCCESS;
+      }
+
+      assert(*pDataSize >= sizeof(*props));
+
       props->minImageCount = MIN_NUM_IMAGES;
       props->maxImageCount = 4;
       props->currentExtent = (VkExtent2D) { -1, -1 };
index 212c01be0b9ffc30ee4aed00d3875ba16fe1c73b..b412a2bab32a4ec0abfd60ef8b5020cc444d48ec 100644 (file)
@@ -59,9 +59,15 @@ x11_get_surface_info(struct anv_wsi_implementation *impl,
 
    switch (infoType) {
    case VK_SURFACE_INFO_TYPE_PROPERTIES_WSI: {
-      assert(*pDataSize >= sizeof(VkSurfacePropertiesWSI));
       VkSurfacePropertiesWSI *props = pData;
 
+      if (pData == NULL) {
+         *pDataSize = sizeof(*props);
+         return VK_SUCCESS;
+      }
+
+      assert(*pDataSize >= sizeof(*props));
+
       props->minImageCount = 2;
       props->maxImageCount = 4;
       props->currentExtent = (VkExtent2D) { -1, -1 };