Skip to content

Commit

Permalink
fix(client): divide by zero error when DNS returns no addrs (#3355)
Browse files Browse the repository at this point in the history
Consider addrs length is 0.

From issue: seanmonstar/reqwest#2003
  • Loading branch information
gngpp authored Oct 19, 2023
1 parent a22c512 commit 41eaf20
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/client/connect/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ struct ConnectingTcpRemote {

impl ConnectingTcpRemote {
fn new(addrs: dns::SocketAddrs, connect_timeout: Option<Duration>) -> Self {
let connect_timeout = connect_timeout.map(|t| t / (addrs.len() as u32));
let connect_timeout = connect_timeout.map(|t| t.checked_div(addrs.len() as u32)).flatten();

Self {
addrs,
Expand Down

0 comments on commit 41eaf20

Please sign in to comment.