Merge 'Update the write_varint method to use an encoded buffer of size 9 instead of 10.' from

The SQLite varint specification states that the varint is guaranteed to
be a maximum of 9 bytes, but our version of write_varint initializes a
buffer of 10 bytes. Changing the size to match the specification.
We could put an assert to check that the 10th byte is never written to
but, reducing the size  seems like the correct thing to do based on the
specification.
Varint constraints are mentioned in this specification:
https://www.sqlite.org/fileformat.html

Closes #3835
This commit is contained in:
Pekka Enberg
2025-10-26 12:27:09 +02:00
committed by GitHub
2 changed files with 2 additions and 2 deletions

View File

@@ -1601,7 +1601,7 @@ pub fn write_varint(buf: &mut [u8], value: u64) -> usize {
return 9;
}
let mut encoded: [u8; 10] = [0; 10];
let mut encoded: [u8; 9] = [0; 9];
let mut bytes = value;
let mut n = 0;
while bytes != 0 {

View File

@@ -130,7 +130,7 @@ pub fn write_varint(buf: &mut [u8], value: u64) -> usize {
return 9;
}
let mut encoded: [u8; 10] = [0; 10];
let mut encoded: [u8; 9] = [0; 9];
let mut bytes = value;
let mut n = 0;
while bytes != 0 {