loader: Do not return OOM when layer count is 0
authorJ.D. Rouan <jdrouan@google.com>
Mon, 1 Feb 2021 22:03:04 +0000 (14:03 -0800)
committerLenny Komow <lenny@lunarg.com>
Wed, 3 Feb 2021 18:34:20 +0000 (11:34 -0700)
commit6fcd515be5b305d9a68ba94b911f84c76a30887e
tree37cfbc62e4496d986bd811bae34abef4d9b83add
parentfd5cc696221374a02437415623ea1778df73199b
loader: Do not return OOM when layer count is 0

An application program that overrides malloc with an implementation that
returns NULL for a zero-sized allocation will cause some loader and
trampoline functions to incorrectly return VK_ERROR_OUT_OF_HOST_MEMORY
if there are no layers on the system. This patch prevents these errors
by also checking the layer count.

Fixes: https://github.com/KhronosGroup/Vulkan-Loader/issues/543
loader/loader.c
loader/trampoline.c