From 096987a31cfdecd74b6e49ede5a4331e3d16fc51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Laignel?= Date: Wed, 2 Jul 2025 13:33:34 +0200 Subject: [PATCH] rtpbin2: sync: fix race condition Under some circumstances, the `ssrc` could be added to the `ssrcs` map without the `clock_rate` being defined. When `rtprecv` would check wether the ssrc `has_clock_rate()`, it would return `true` spuriously, which would then cause a panic in `calculate_pts()`. Part-of: --- net/rtp/src/rtpbin2/sync.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/net/rtp/src/rtpbin2/sync.rs b/net/rtp/src/rtpbin2/sync.rs index 2b62341b4..5f41031f9 100644 --- a/net/rtp/src/rtpbin2/sync.rs +++ b/net/rtp/src/rtpbin2/sync.rs @@ -119,7 +119,9 @@ impl Context { } pub fn has_clock_rate(&self, ssrc_val: u32) -> bool { - self.ssrcs.contains_key(&ssrc_val) + self.ssrcs + .get(&ssrc_val) + .is_some_and(|ssrc| ssrc.clock_rate.is_some()) } fn disassociate(&mut self, ssrc_val: u32, cname: &str) {