Skip to content

Commit

Permalink
Fixed potential overflow in multiview vertex buffer validation (#1855)
Browse files Browse the repository at this point in the history
  • Loading branch information
m3x3 authored Mar 10, 2022
1 parent 5d20cc4 commit e1558f6
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion vulkano/src/command_buffer/validity/vertex_buffers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,10 @@ pub(in super::super) fn check_vertex_buffers(
.max_multiview_instance_index
.unwrap_or(0);

if first_instance + instance_count > max_instance_index + 1 {
// The condition is somewhat convoluted to avoid integer overflows.
let out_of_range = first_instance > max_instance_index
|| (instance_count > 0 && instance_count - 1 > max_instance_index - first_instance);
if out_of_range {
return Err(CheckVertexBufferError::TooManyInstances {
instance_count,
max_instance_count: max_instance_index + 1, // TODO: this can overflow
Expand Down

0 comments on commit e1558f6

Please # to comment.