]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
[Core] Coverity fixes
authorDragos Oancea <dragos@signalwire.com>
Wed, 5 Apr 2023 15:54:11 +0000 (18:54 +0300)
committerGitHub <noreply@github.com>
Wed, 5 Apr 2023 15:54:11 +0000 (18:54 +0300)
* [core] coverity CID 1320751 (Dereference before null check)

* [core] coverity CID 1294546 (Unchecked return value)

* [core] coverity CID 1227661 (Logically dead code)

* [core] coverity CID 1227656 (Logically dead code)

* [core] coverity CID 1060948 (Explicit null dereferenced)

* [core] coverity CID 1346465 (Unchecked return value)

* [core] coverity CID 1364953 (Logically dead code)

* [core] coverity CID 1468210 (Dereference before null check)

* [core] coverity CID 1468546 (Dereference before null check)

* [core] coverity CID 1468342 (Dereference before null check)

src/switch_core_media.c
src/switch_ivr_async.c
src/switch_ivr_bridge.c
src/switch_nat.c
src/switch_rtp.c

index d4954ee6b13519eb894dc8dbc2c1907081c5502d..912d5a501239181b43a01ff18d10cf013ca69450 100644 (file)
@@ -6672,10 +6672,6 @@ SWITCH_DECLARE(void) switch_core_session_write_blank_video(switch_core_session_t
        if (!height) height = 288;
        if (!fps) fps = 15;
 
-       if (!(width && height && fps)) {
-               return;
-       }
-
        fr.packet = buf;
        fr.packetlen = buflen;
        fr.data = buf + 12;
@@ -12439,7 +12435,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_media_params(switch_core_sessi
                                *val++ = '\0';
                        }
 
-                       if (name && val) {
+                       if (val) {
                                if (!strcmp(name, "aspect")) {
                                        aspect = val;
                                        vid++;
@@ -15860,7 +15856,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_write_frame(switch_core_sess
 
        if (!(switch_core_codec_ready(session->write_codec) && switch_core_codec_ready(frame->codec))) goto error;
 
-       if ((session->write_codec && frame->codec && session->write_codec->implementation != frame->codec->implementation)) {
+       if (frame->codec && session->write_codec->implementation != frame->codec->implementation) {
                if (session->write_impl.codec_id == frame->codec->implementation->codec_id ||
                        session->write_impl.microseconds_per_packet != frame->codec->implementation->microseconds_per_packet) {
                        ptime_mismatch = TRUE;
index d00b75d40cd4114f4bbd90f38f0a7b81a7f027ab..9a33b43340e785d2a791948feec19d161034745d 100644 (file)
@@ -2130,7 +2130,7 @@ static switch_bool_t eavesdrop_callback(switch_media_bug_t *bug, void *user_data
                                break;
                        }
 
-                       if (ep->eavesdropper && switch_core_session_read_lock(ep->eavesdropper) == SWITCH_STATUS_SUCCESS) {
+                       if (switch_core_session_read_lock(ep->eavesdropper) == SWITCH_STATUS_SUCCESS) {
                                if (switch_core_session_write_video_frame(ep->eavesdropper, bug->video_ping_frame, SWITCH_IO_FLAG_NONE, 0) != SWITCH_STATUS_SUCCESS) {
                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Error writing video to %s\n", switch_core_session_get_name(ep->eavesdropper));
                                        ep->errs++;
@@ -2178,10 +2178,11 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_eavesdrop_pop_eavesdropper(switch_cor
                struct eavesdrop_pvt *ep = (struct eavesdrop_pvt *) switch_core_media_bug_get_user_data(bug);
 
                if (ep && ep->eavesdropper && ep->eavesdropper != session) {
-                       switch_core_session_read_lock(ep->eavesdropper);
-                       *sessionp = ep->eavesdropper;
-                       switch_core_media_bug_set_flag(bug, SMBF_PRUNE);
-                       status = SWITCH_STATUS_SUCCESS;
+                       if (switch_core_session_read_lock(ep->eavesdropper) == SWITCH_STATUS_SUCCESS) {
+                               *sessionp = ep->eavesdropper;
+                               switch_core_media_bug_set_flag(bug, SMBF_PRUNE);
+                               status = SWITCH_STATUS_SUCCESS;
+                       }
                }
        }
 
index f91fc2c69f3ff49107d6d21920c42fd2856770e8..527058f70c02821e2c21e81d4237f820b817ef17 100644 (file)
@@ -237,7 +237,7 @@ static void video_bridge_thread(switch_core_session_t *session, void *obj)
                        continue;
                }
 
-               if (switch_channel_media_up(b_channel)) {
+               if (read_frame && switch_channel_media_up(b_channel)) {
                        if (switch_core_session_write_video_frame(vh->session_b, read_frame, SWITCH_IO_FLAG_NONE, 0) != SWITCH_STATUS_SUCCESS) {
                                switch_cond_next();
                                continue;
index f6b9bc553b859c2c6b8e81b05a8b66eeb00a7250..a1620b4bfd71f8132e912f1e24d51f3492cb3c30 100644 (file)
@@ -506,7 +506,7 @@ static switch_status_t switch_nat_add_mapping_upnp(switch_port_t port, switch_na
 
        if (r == UPNPCOMMAND_SUCCESS) {
                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "mapped public port %s protocol %s to localport %s\n", port_str,
-                                                 (proto == SWITCH_NAT_TCP) ? "TCP" : (proto == SWITCH_NAT_UDP ? "UDP" : "UNKNOWN"), port_str);
+                                                 (proto == SWITCH_NAT_TCP) ? "TCP" : "UDP", port_str);
                status = SWITCH_STATUS_SUCCESS;
        }
 
@@ -566,7 +566,7 @@ static switch_status_t switch_nat_del_mapping_upnp(switch_port_t port, switch_na
 
        if (r == UPNPCOMMAND_SUCCESS) {
                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "unmapped public port %s protocol %s to localport %s\n", port_str,
-                                                 (proto == SWITCH_NAT_TCP) ? "TCP" : (proto == SWITCH_NAT_UDP ? "UDP" : "UNKNOWN"), port_str);
+                                                 (proto == SWITCH_NAT_TCP) ? "TCP" : "UDP", port_str);
                status = SWITCH_STATUS_SUCCESS;
        }
        return status;
index 83987178188182d34c35d2f00c08b02c60422eb9..ad9f8eef1ce6f6c54afadc031aa2dba04c15537f 100644 (file)
@@ -1277,7 +1277,7 @@ static void handle_ice(switch_rtp_t *rtp_session, switch_rtp_ice_t *ice, void *d
                                }
                                
                                
-                               if (ice->ice_params && ice->ice_params->cands[ice->ice_params->chosen[ice->proto]][ice->proto].cand_type &&
+                               if (ice->ice_params->cands[ice->ice_params->chosen[ice->proto]][ice->proto].cand_type &&
                                        !strcasecmp(ice->ice_params->cands[ice->ice_params->chosen[ice->proto]][ice->proto].cand_type, "relay")) {
                                        do_adj++;
                                }
@@ -3010,7 +3010,7 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_set_remote_address(switch_rtp_t *rtp_
                rtp_session->dtls->sock_output = rtp_session->sock_output;
 
                if (rtp_session->flags[SWITCH_RTP_FLAG_RTCP_MUX]) {
-                       switch_sockaddr_info_get(&rtp_session->dtls->remote_addr, host, SWITCH_UNSPEC, port, 0, rtp_session->pool);
+                       status = switch_sockaddr_info_get(&rtp_session->dtls->remote_addr, host, SWITCH_UNSPEC, port, 0, rtp_session->pool);
                }
        }