[Mesa-dev] [PATCH] anv: pCreateInfo->pApplicationInfo parameter to vkCreateInstance may be NULL

Jason Ekstrand jason at jlekstrand.net
Tue Feb 16 22:43:33 UTC 2016


On Tue, Feb 16, 2016 at 1:55 PM, Philipp Zabel <philipp.zabel at gmail.com>
wrote:

> Fix a NULL pointer dereference in anv_CreateInstance in case
> the pApplicationInfo field of the supplied VkInstanceCreateInfo
> structure is NULL [1].
>
> [1]
> https://www.khronos.org/registry/vulkan/specs/1.0/apispec.html#VkInstanceCreateInfo
>
> Signed-off-by: Philipp Zabel <philipp.zabel at gmail.com>
> ---
>  src/vulkan/anv_device.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/src/vulkan/anv_device.c b/src/vulkan/anv_device.c
> index a6ce176..6863906 100644
> --- a/src/vulkan/anv_device.c
> +++ b/src/vulkan/anv_device.c
> @@ -214,7 +214,9 @@ VkResult anv_CreateInstance(
>
>     assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO);
>
> -   uint32_t client_version = pCreateInfo->pApplicationInfo->apiVersion;
> +   uint32_t client_version = pCreateInfo->pApplicationInfo ?
> +                             pCreateInfo->pApplicationInfo->apiVersion :
> +                             VK_MAKE_VERSION(1, 0, 0);
>

That seems like a reasonable thing to do.  Kind of silly not to provide a
version though.

Pushed.  thanks!


>     if (VK_MAKE_VERSION(1, 0, 0) > client_version ||
>         client_version > VK_MAKE_VERSION(1, 0, 3)) {
>        return vk_errorf(VK_ERROR_INCOMPATIBLE_DRIVER,
> @@ -249,7 +251,7 @@ VkResult anv_CreateInstance(
>     else
>        instance->alloc = default_alloc;
>
> -   instance->apiVersion = pCreateInfo->pApplicationInfo->apiVersion;
> +   instance->apiVersion = client_version;
>     instance->physicalDeviceCount = -1;
>
>     _mesa_locale_init();
> --
> 2.7.0
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20160216/0f054839/attachment.html>


More information about the mesa-dev mailing list