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
1 changed files with 6 additions and 5 deletions
|
@ -658,6 +658,12 @@ impl MetalRenderer {
|
||||||
|
|
||||||
let underline_bytes_len = mem::size_of_val(underlines);
|
let underline_bytes_len = mem::size_of_val(underlines);
|
||||||
let buffer_contents = unsafe { (self.instances.contents() as *mut u8).add(*offset) };
|
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 {
|
unsafe {
|
||||||
ptr::copy_nonoverlapping(
|
ptr::copy_nonoverlapping(
|
||||||
underlines.as_ptr() as *const u8,
|
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(
|
command_encoder.draw_primitives_instanced(
|
||||||
metal::MTLPrimitiveType::Triangle,
|
metal::MTLPrimitiveType::Triangle,
|
||||||
0,
|
0,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue