mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-10-07 09:38:11 +08:00
Guard attribute writes against an uninstalled layout offset
This commit is contained in:
@@ -130,8 +130,14 @@ impl<'e, 'l> FrameClaim<'e, 'l> {
|
|||||||
/// Writes a field at its wiring-resolved offset.
|
/// Writes a field at its wiring-resolved offset.
|
||||||
///
|
///
|
||||||
/// # Safety
|
/// # Safety
|
||||||
/// `offset` must be this layout's resolved offset for a field of `T`.
|
/// `offset` must be this layout's resolved offset for a field of `T`. A
|
||||||
|
/// generated write offset defaults to 0 until `set_layout` installs it, so
|
||||||
|
/// the debug assertion catches a serve that ran before the install.
|
||||||
pub unsafe fn attr_at<T>(&mut self, offset: usize, value: T) {
|
pub unsafe fn attr_at<T>(&mut self, offset: usize, value: T) {
|
||||||
|
debug_assert!(
|
||||||
|
self.layout.fields.iter().any(|field| field.offset == offset),
|
||||||
|
"attribute write at an offset this layout does not carry; the layout must install before serving"
|
||||||
|
);
|
||||||
unsafe { write_field(self.dst(), offset, value) };
|
unsafe { write_field(self.dst(), offset, value) };
|
||||||
self.filled_fields = true;
|
self.filled_fields = true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user