mirror of
https://github.com/zed-industries/zed.git
synced 2024-12-28 15:44:20 +03:00
Check if we exhausted the instance buffer prior to copying underlines
This fixes another potential segfault.
This commit is contained in:
parent
97bd3e1fde
commit
9c33790809
@ -658,6 +658,12 @@ impl MetalRenderer {
|
||||
|
||||
let underline_bytes_len = mem::size_of_val(underlines);
|
||||
let buffer_contents = unsafe { (self.instances.contents() as *mut u8).add(*offset) };
|
||||
|
||||
let next_offset = *offset + underline_bytes_len;
|
||||
if next_offset > INSTANCE_BUFFER_SIZE {
|
||||
return false;
|
||||
}
|
||||
|
||||
unsafe {
|
||||
ptr::copy_nonoverlapping(
|
||||
underlines.as_ptr() as *const u8,
|
||||
@ -666,11 +672,6 @@ impl MetalRenderer {
|
||||
);
|
||||
}
|
||||
|
||||
let next_offset = *offset + underline_bytes_len;
|
||||
if next_offset > INSTANCE_BUFFER_SIZE {
|
||||
return false;
|
||||
}
|
||||
|
||||
command_encoder.draw_primitives_instanced(
|
||||
metal::MTLPrimitiveType::Triangle,
|
||||
0,
|
||||
|
Loading…
Reference in New Issue
Block a user