[core] Coverity fixes

* [core] Coverity CID 1024233 (Dereference before null check)

* [core] Coverity CID 1024239 (Dereference before null check)

* [core] Coverity CID 1024242 (Dereference before null check)

* [core] Coverity CID 1024243 (Dereference before null check)

* [core] Coverity CID 1024453 (Dereference before null check)

* [core] Coverity CID 1024554 (Logically dead code)

* [core] Coverity CID 1024868 (unchecked return value from library)

* [core] Coverity CID 1024869 (unchecked return value from library)

* [core] Coverity CID 1468281 (Dereference before null check)

* [core] Coverity CID 1024238 (Dereference before null check)

* [core] Coverity CID 1468621 (Copy into fixed size buffer)

* [core] Coverity CID 1024871 (Unchecked return value)
This commit is contained in:
Jakub Karolczyk
2023-07-21 11:49:40 +01:00
committed by GitHub
parent e764f292b5
commit 55f2dc4759
5 changed files with 58 additions and 41 deletions
+8 -2
View File
@@ -120,8 +120,9 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_set_real_read_codec(switch_c
}
} else { /* replace real_read_codec */
switch_codec_t *cur_codec;
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s Original read codec replaced with %s:%d\n",
switch_channel_get_name(session->channel), codec->implementation->iananame, codec->implementation->ianacode);
switch_channel_get_name(session->channel), codec->implementation ? codec->implementation->iananame : "undefined", codec->implementation ? codec->implementation->ianacode : -1);
/* Set real_read_codec to front of the list of read_codecs */
cur_codec = session->read_codec;
while (cur_codec != NULL) {
@@ -129,8 +130,10 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_set_real_read_codec(switch_c
cur_codec->next = codec;
break;
}
cur_codec = cur_codec->next;
}
session->real_read_codec = codec;
session->real_read_impl = *codec->implementation;
@@ -154,6 +157,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_set_real_read_codec(switch_c
session->bug_codec.implementation->iananame, session->bug_codec.implementation->ianacode);
switch_core_codec_destroy(&session->bug_codec);
}
switch_thread_rwlock_unlock(session->bug_rwlock);
} else {
status = SWITCH_STATUS_FALSE;
@@ -169,6 +173,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_set_real_read_codec(switch_c
if (session->read_impl.actual_samples_per_second != session->read_impl.samples_per_second) {
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "channel-reported-read-codec-rate", "%d", session->read_impl.samples_per_second);
}
switch_event_fire(&event);
}
@@ -191,6 +196,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_set_real_read_codec(switch_c
}
switch_mutex_unlock(session->codec_read_mutex);
return status;
}
@@ -221,7 +227,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_set_read_codec(switch_core_s
goto end;
}
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s Push codec %s:%d\n",
switch_channel_get_name(session->channel), codec->implementation->iananame, codec->implementation->ianacode);
switch_channel_get_name(session->channel), codec->implementation ? codec->implementation->iananame : "undefined", codec->implementation ? codec->implementation->ianacode : -1);
codec->next = session->read_codec;
session->read_codec = codec;
if (codec->implementation) {