From 7939144ef80191ceae281582589986d4e6f37c0e Mon Sep 17 00:00:00 2001 From: Christopher Berner Date: Fri, 24 Nov 2023 19:54:30 -0800 Subject: [PATCH] Fix division by zero when packet size is less than 32 --- src/base.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/base.rs b/src/base.rs index 8f47654..2f9658f 100644 --- a/src/base.rs +++ b/src/base.rs @@ -202,10 +202,13 @@ impl ObjectTransmissionInformation { max_packet_size: u16, decoder_memory_requirement: u64, ) -> ObjectTransmissionInformation { - let alignment = 8; + let (alignment, sub_symbol_size) = if max_packet_size >= 8 * 8 { + (8, 8) + } else { + (1, 1) + }; assert!(max_packet_size >= alignment); let symbol_size = max_packet_size - (max_packet_size % alignment); - let sub_symbol_size = 8; let kt = int_div_ceil(transfer_length, symbol_size as u64);