Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d7ea44ab authored by Yiwei Zhang's avatar Yiwei Zhang
Browse files

libvulkan: avoid allocation if final extension count is zero

This change also makes sure ExtensionFilter is properly initialized.

Bug: 161810298
Test: dEQP-VK.api.object_management.max_concurrent#instance
Change-Id: I2e3526b38fc5eeddf0e96d18dfd6f218bbb80201
parent 249afbf1
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -120,6 +120,8 @@ class CreateInfoWrapper {

        const char** names;
        uint32_t name_count;
        ExtensionFilter()
            : exts(nullptr), ext_count(0), names(nullptr), name_count(0) {}
    };

    VkResult SanitizeApiVersion();
@@ -607,6 +609,10 @@ VkResult CreateInfoWrapper::InitExtensionFilter() {
    } else {
        count = std::min(filter.ext_count, dev_info_.enabledExtensionCount);
    }

    if (!count)
        return VK_SUCCESS;

    filter.names = reinterpret_cast<const char**>(allocator_.pfnAllocation(
        allocator_.pUserData, sizeof(const char*) * count, alignof(const char*),
        VK_SYSTEM_ALLOCATION_SCOPE_COMMAND));