Skip to content

Commit 63339e8

Browse files
committed
transmit: Fix crash when NULL parent module is passed
1 parent 2841520 commit 63339e8

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/transmit.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,8 @@ struct tx *tx_init(struct module *parent, unsigned mtu, enum tx_media_type media
259259

260260
tx->bitrate = bitrate;
261261

262-
tx->control = (struct control_state *) get_module(get_root_module(parent), "control");
262+
if(parent)
263+
tx->control = (struct control_state *) get_module(get_root_module(parent), "control");
263264

264265
return tx;
265266
}
@@ -727,7 +728,7 @@ tx_send_base(struct tx *tx, struct video_frame *frame, struct rtp *rtp_session,
727728
data = encrypted_data;
728729
}
729730

730-
if (control_stats_enabled(tx->control)) {
731+
if (tx->control && control_stats_enabled(tx->control)) {
731732
auto current_time_ms = time_since_epoch_in_ms();
732733
if(current_time_ms - tx->last_stat_report >= CONTROL_PORT_BANDWIDTH_REPORT_INTERVAL_MS){
733734
std::ostringstream oss;
@@ -900,7 +901,7 @@ void audio_tx_send(struct tx* tx, struct rtp *rtp_session, const audio_frame2 *
900901
data = encrypted_data;
901902
}
902903

903-
if (control_stats_enabled(tx->control)) {
904+
if (tx->control && control_stats_enabled(tx->control)) {
904905
auto current_time_ms = time_since_epoch_in_ms();
905906
if(current_time_ms - tx->last_stat_report >= CONTROL_PORT_BANDWIDTH_REPORT_INTERVAL_MS){
906907
std::ostringstream oss;

0 commit comments

Comments
 (0)