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

Commit e6080bf2 authored by Jesse Hall's avatar Jesse Hall
Browse files

libvulkan: Check for negative in signed -> unsigned conversion

Requested during security audit in bug 27118888.

Change-Id: Id82382258d2b6f8523b8af29f494dfc67100d190
parent c4eee83b
Loading
Loading
Loading
Loading
+8 −6
Original line number Diff line number Diff line
@@ -511,16 +511,18 @@ VkResult CreateSwapchainKHR_Bottom(VkDevice device,
        return VK_ERROR_INITIALIZATION_FAILED;
    }

    uint32_t min_undequeued_buffers;
    err = surface.window->query(
        surface.window.get(), NATIVE_WINDOW_MIN_UNDEQUEUED_BUFFERS,
        reinterpret_cast<int*>(&min_undequeued_buffers));
    if (err != 0) {
    int query_value;
    err = surface.window->query(surface.window.get(),
                                NATIVE_WINDOW_MIN_UNDEQUEUED_BUFFERS,
                                &query_value);
    if (err != 0 || query_value < 0) {
        // TODO(jessehall): Improve error reporting. Can we enumerate possible
        // errors and translate them to valid Vulkan result codes?
        ALOGE("window->query failed: %s (%d)", strerror(-err), err);
        ALOGE("window->query failed: %s (%d) value=%d", strerror(-err), err,
              query_value);
        return VK_ERROR_INITIALIZATION_FAILED;
    }
    uint32_t min_undequeued_buffers = static_cast<uint32_t>(query_value);
    // The MIN_UNDEQUEUED_BUFFERS query doesn't know whether we'll be using
    // async mode or not, and assumes not. But in async mode, the BufferQueue
    // requires an extra undequeued buffer.