From 2cb0a9b34b0deb0ddabdc255cdef0fa1f2ad935f Mon Sep 17 00:00:00 2001 From: Bob Peterson Date: Sun, 19 Oct 2025 23:38:34 -0500 Subject: [PATCH] Use read_unaligned with *u8 cast to *u32 Avoids undefined behavior due to unaligned read caught with Miri --- core/storage/btree.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/storage/btree.rs b/core/storage/btree.rs index 31e89b01f..65659c4b3 100644 --- a/core/storage/btree.rs +++ b/core/storage/btree.rs @@ -2857,7 +2857,8 @@ impl BTreeCursor { // load sibling pages // start loading right page first - let mut pgno: u32 = unsafe { right_pointer.cast::().read().swap_bytes() }; + let mut pgno: u32 = + unsafe { right_pointer.cast::().read_unaligned().swap_bytes() }; let current_sibling = sibling_pointer; let mut group = CompletionGroup::new(|_| {}); for i in (0..=current_sibling).rev() {