bugfix: clear reserved space for a reused page

This commit is contained in:
Avinash Sajjanshetty
2025-09-18 17:51:30 +05:30
parent 84cf3640cb
commit 91e2a679b9

View File

@@ -6565,6 +6565,20 @@ pub fn btree_init_page(page: &PageRef, page_type: PageType, offset: usize, usabl
contents.write_fragmented_bytes_count(0);
contents.write_rightmost_ptr(0);
#[cfg(debug_assertions)]
{
// we might get already used page from the pool. generally this is not a problem because
// b tree access is very controlled. However, for encrypted pages (and also checksums) we want
// to ensure that there are no reserved bytes that contain old data.
let buffer_len = contents.buffer.len();
turso_assert!(
usable_space <= buffer_len,
"usable_space must be <= buffer_len"
);
// this is no op if usable_space == buffer_len
contents.as_ptr()[usable_space..buffer_len].fill(0);
}
}
fn to_static_buf(buf: &mut [u8]) -> &'static mut [u8] {