This is an automated email from the ASF dual-hosted git repository. kriskras99 pushed a commit to branch small_fixes in repository https://gitbox.apache.org/repos/asf/avro-rs.git
commit 791fcb507e32bb18062b019147605586f7e44432 Author: Kriskras99 <[email protected]> AuthorDate: Wed Nov 12 13:48:41 2025 +0100 fix: Make zigzag encoding endianness agnostic --- avro/src/util.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/avro/src/util.rs b/avro/src/util.rs index 1c986f4..c6b7a59 100644 --- a/avro/src/util.rs +++ b/avro/src/util.rs @@ -83,7 +83,7 @@ pub(crate) fn zig_i32<W: Write>(n: i32, buffer: W) -> AvroResult<usize> { } pub(crate) fn zig_i64<W: Write>(n: i64, writer: W) -> AvroResult<usize> { - encode_variable(((n << 1) ^ (n >> 63)) as u64, writer) + encode_variable(n, writer) } pub(crate) fn zag_i32<R: Read>(reader: &mut R) -> AvroResult<i32> { @@ -100,7 +100,8 @@ pub(crate) fn zag_i64<R: Read>(reader: &mut R) -> AvroResult<i64> { }) } -fn encode_variable<W: Write>(mut z: u64, mut writer: W) -> AvroResult<usize> { +fn encode_variable<W: Write>(n: i64, mut writer: W) -> AvroResult<usize> { + let mut z = (((n << 1) ^ (n >> 63)) as u64).to_le(); let mut buffer = [0u8; 10]; let mut i: usize = 0; loop {
