1
0
Fork 0
mirror of https://codeberg.org/demostf/parser.git synced 2026-06-03 10:14:06 +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,
) -> ReadResult<()> {
let abs = if signed {
let int = (int << 1) ^ -(int & 1);
let int = (int << 1) ^ (int >> 31);
u32::from_le_bytes(int.to_le_bytes())
} else {
int as u32