mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-15 14:02:20 +00:00
LibGfx: VulkanContext coverity reports integer_overflow on index
Some checks are pending
CI / macOS, arm64, Sanitizer, Clang (push) Waiting to run
CI / Linux, x86_64, Fuzzers, Clang (push) Waiting to run
CI / Linux, x86_64, Sanitizer, GNU (push) Waiting to run
CI / Linux, x86_64, Sanitizer, Clang (push) Waiting to run
Package the js repl as a binary artifact / Linux, arm64 (push) Waiting to run
Package the js repl as a binary artifact / macOS, arm64 (push) Waiting to run
Package the js repl as a binary artifact / Linux, x86_64 (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run
Some checks are pending
CI / macOS, arm64, Sanitizer, Clang (push) Waiting to run
CI / Linux, x86_64, Fuzzers, Clang (push) Waiting to run
CI / Linux, x86_64, Sanitizer, GNU (push) Waiting to run
CI / Linux, x86_64, Sanitizer, Clang (push) Waiting to run
Package the js repl as a binary artifact / Linux, arm64 (push) Waiting to run
Package the js repl as a binary artifact / macOS, arm64 (push) Waiting to run
Package the js repl as a binary artifact / Linux, x86_64 (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run
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
Notes:
github-actions[bot]
2025-07-28 03:39:51 +00:00
Author: https://github.com/rcorsi
Commit: d322c3a21f
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5595
Reviewed-by: https://github.com/kalenikaliaksandr ✅
1 changed files with 9 additions and 4 deletions
|
@ -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…
Add table
Add a link
Reference in a new issue