mirror of
https://github.com/zebrajr/ladybird.git
synced 2025-12-06 00:19:53 +01:00
LibGfx: VulkanContext coverity reports integer_overflow on index
Coverity static analysis reports that the code that scans the queue families for one that has the graphics bit, can be -1 if none are found, which could cause a problem when the -1 (signed) value is used later as an index in a uint32_t (unsigned) variable. Its not immediately clear how often this could occur, not finding a queue family with the graphics bit, but adding some protecting just in case.
This commit is contained in:
parent
bc4112bf18
commit
d322c3a21f
|
|
@ -75,14 +75,19 @@ static ErrorOr<VkDevice> create_logical_device(VkPhysicalDevice physical_device)
|
|||
queue_families.resize(queue_family_count);
|
||||
vkGetPhysicalDeviceQueueFamilyProperties(physical_device, &queue_family_count, queue_families.data());
|
||||
|
||||
int graphics_queue_family_index = -1;
|
||||
for (int i = 0; i < static_cast<int>(queue_families.size()); i++) {
|
||||
if (queue_families[i].queueFlags & VK_QUEUE_GRAPHICS_BIT) {
|
||||
graphics_queue_family_index = i;
|
||||
bool graphics_queue_family_found = false;
|
||||
uint32_t graphics_queue_family_index = 0;
|
||||
for (; graphics_queue_family_index < queue_families.size(); ++graphics_queue_family_index) {
|
||||
if (queue_families[graphics_queue_family_index].queueFlags & VK_QUEUE_GRAPHICS_BIT) {
|
||||
graphics_queue_family_found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!graphics_queue_family_found) {
|
||||
return Error::from_string_literal("Graphics queue family not found");
|
||||
}
|
||||
|
||||
VkDeviceQueueCreateInfo queue_create_info {};
|
||||
queue_create_info.sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO;
|
||||
queue_create_info.queueFamilyIndex = graphics_queue_family_index;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user