Skip to content

Commit

Permalink
Check if ice strans is valid before using it to send (#4301)
Browse files Browse the repository at this point in the history
  • Loading branch information
trengginas authored Feb 12, 2025
1 parent fdd4041 commit 6cbf0e6
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions pjmedia/src/pjmedia/transport_ice.c
Original file line number Diff line number Diff line change
Expand Up @@ -2458,8 +2458,12 @@ static pj_status_t transport_send_rtp(pjmedia_transport *tp,
pj_size_t size)
{
struct transport_ice *tp_ice = (struct transport_ice*)tp;
pj_ice_strans *ice_st = tp_ice->ice_st;
pj_status_t status;

if (!ice_st)
return PJ_SUCCESS;

/* Simulate packet lost on TX direction */
if (tp_ice->tx_drop_pct) {
if ((pj_rand() % 100) <= (int)tp_ice->tx_drop_pct) {
Expand All @@ -2470,7 +2474,7 @@ static pj_status_t transport_send_rtp(pjmedia_transport *tp,
}
}

status = pj_ice_strans_sendto2(tp_ice->ice_st, 1,
status = pj_ice_strans_sendto2(ice_st, 1,
pkt, size, &tp_ice->remote_rtp,
tp_ice->addr_len);
if (status == PJ_EPENDING)
Expand All @@ -2494,6 +2498,10 @@ static pj_status_t transport_send_rtcp2(pjmedia_transport *tp,
pj_size_t size)
{
struct transport_ice *tp_ice = (struct transport_ice*)tp;
pj_ice_strans *ice_st = tp_ice->ice_st;

if (!ice_st)
return PJ_SUCCESS;

if (tp_ice->comp_cnt > 1 || tp_ice->use_rtcp_mux) {
pj_status_t status;
Expand All @@ -2504,7 +2512,7 @@ static pj_status_t transport_send_rtcp2(pjmedia_transport *tp,
addr_len = pj_sockaddr_get_len(addr);
}

status = pj_ice_strans_sendto2(tp_ice->ice_st, comp_id, pkt, size,
status = pj_ice_strans_sendto2(ice_st, comp_id, pkt, size,
addr, addr_len);
if (status == PJ_EPENDING)
status = PJ_SUCCESS;
Expand Down

0 comments on commit 6cbf0e6

Please sign in to comment.