1
0
Fork 0
mirror of https://codeberg.org/demostf/parser.git synced 2026-06-03 18:24:05 +02:00

fix signed varint encoding

This commit is contained in:
Robin Appelman 2021-07-22 16:54:04 +02:00
commit 60f23647c5

View file

@ -1107,7 +1107,7 @@ pub fn write_var_int(
signed: bool, signed: bool,
) -> ReadResult<()> { ) -> ReadResult<()> {
let abs = if signed { let abs = if signed {
let int = (int << 1) ^ -(int & 1); let int = (int << 1) ^ (int >> 31);
u32::from_le_bytes(int.to_le_bytes()) u32::from_le_bytes(int.to_le_bytes())
} else { } else {
int as u32 int as u32