Skip to content

Commit 430068d

Browse files
committed
Fixed overflow
1 parent 87d37c3 commit 430068d

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

audio/src/fetch/receive.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,9 @@ async fn receive_data(
120120
if measure_throughput {
121121
let duration = Instant::now().duration_since(request_time).as_millis();
122122
if actual_length > 0 && duration > 0 {
123-
let throughput = ONE_SECOND.as_millis() as usize * actual_length / duration as usize;
124-
file_data_tx.send(ReceivedData::Throughput(throughput))?;
123+
// Use u64 for intermediate calculation to avoid overflow on 32-bit platforms
124+
let throughput = ONE_SECOND.as_millis() as u64 * actual_length as u64 / duration as u64;
125+
file_data_tx.send(ReceivedData::Throughput(throughput as usize))?;
125126
}
126127
}
127128

0 commit comments

Comments
 (0)