]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-11903: Fix errors reported by PVS-Studio Static Code Analyzer for mod_spandsp
authorAndrey Volk <andywolk@gmail.com>
Fri, 12 Jul 2019 16:52:25 +0000 (20:52 +0400)
committerAndrey Volk <andywolk@gmail.com>
Mon, 15 Jul 2019 19:47:05 +0000 (23:47 +0400)
src/mod/applications/mod_spandsp/mod_spandsp.c
src/mod/applications/mod_spandsp/mod_spandsp_codecs.c
src/mod/applications/mod_spandsp/mod_spandsp_fax.c
src/mod/applications/mod_spandsp/mod_spandsp_modem.c
src/mod/applications/mod_spandsp/udptl.c

index 7d8c0d1e63612efca1d246724cbaea2c9b8aefa1..c8802ed15da0465508d5f323327dcb64a52517e2 100644 (file)
@@ -282,6 +282,8 @@ SWITCH_STANDARD_API(start_tone_detect_api)
 
        puuid = strdup((char *)cmd);
 
+       switch_assert(puuid);
+
        if ((descriptor = strchr(puuid, ' '))) {
                *descriptor++ = '\0';
        }
@@ -367,7 +369,7 @@ SWITCH_STANDARD_API(start_tdd_detect_api)
                return SWITCH_STATUS_SUCCESS;
        }
 
-       spandsp_tdd_decode_session(psession);
+       status = spandsp_tdd_decode_session(psession);
 
        if (status == SWITCH_STATUS_SUCCESS) {
                stream->write_function(stream, "+OK started\n");
@@ -413,6 +415,8 @@ SWITCH_STANDARD_API(start_send_tdd_api)
 
        puuid = strdup((char *)cmd);
 
+       switch_assert(puuid);
+
        if ((text = strchr(puuid, ' '))) {
                *text++ = '\0';
        }
index a4c6ba22236fb857814f3b53369ac75c9f0eb3d3..93f4462230fe28b5685b585c0972cf741a9e2f8a 100644 (file)
@@ -463,7 +463,7 @@ static switch_status_t switch_g726_init(switch_codec_t *codec, switch_codec_flag
                return SWITCH_STATUS_FALSE;
        }
 
-       if ((flags & SWITCH_CODEC_FLAG_AAL2 || strstr(codec->implementation->iananame, "AAL2"))) {
+       if (flags & SWITCH_CODEC_FLAG_AAL2 || strstr(codec->implementation->iananame, "AAL2")) {
                packing = G726_PACKING_LEFT;
        }
 
index b75ac89423bec8c5682458a992c1b68675f5d2f9..2931f7414ca57dbd202ef5a3dd4cc2442e1e0c0f 100644 (file)
@@ -824,9 +824,7 @@ static switch_status_t spanfax_init(pvt_t *pvt, transport_mode_t trans_mode)
 
                        /* add to timer thread processing */
                        if (!add_pvt(pvt)) {
-                               if (channel) {
-                                       switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
-                               }
+                               switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
                        }
 
                        span_log_set_message_handler(t38_terminal_get_logging_state(t38), mod_spandsp_log_message, pvt->session);
@@ -1027,12 +1025,17 @@ static switch_status_t spanfax_destroy(pvt_t *pvt)
 
 static t38_mode_t configure_t38(pvt_t *pvt)
 {
-       switch_core_session_t *session = pvt->session;
-       switch_channel_t *channel = switch_core_session_get_channel(session);
-       switch_t38_options_t *t38_options = switch_channel_get_private(channel, "t38_options");
+       switch_core_session_t *session;
+       switch_channel_t *channel;
+       switch_t38_options_t *t38_options;
        int method = 2;
 
-       if (!t38_options || !pvt || !pvt->t38_core) {
+       switch_assert(pvt && pvt->session);
+       session = pvt->session;
+       channel = switch_core_session_get_channel(session);
+       t38_options = switch_channel_get_private(channel, "t38_options");
+
+       if (!t38_options || !pvt->t38_core) {
                pvt->t38_mode = T38_MODE_REFUSED;
                return pvt->t38_mode;
        }
@@ -2364,7 +2367,7 @@ switch_status_t spandsp_fax_detect_session(switch_core_session_t *session,
                return SWITCH_STATUS_FALSE;
        }
 
-       if (!cont && !(cont = switch_core_session_alloc(session, sizeof(*cont)))) {
+       if (!(cont = switch_core_session_alloc(session, sizeof(*cont)))) {
                return SWITCH_STATUS_MEMERR;
        }
 
index 21c4296871ffdb859cefecef7f951b996a59430b..5613b4aa4c6899443856c6ef41fd1649118becf1 100644 (file)
@@ -744,8 +744,6 @@ static switch_status_t channel_receive_message(switch_core_session_t *session, s
        case SWITCH_MESSAGE_INDICATE_RINGING:
                break;
        case SWITCH_MESSAGE_INDICATE_BRIDGE:
-               mod_spandsp_indicate_data(session, SWITCH_FALSE, SWITCH_TRUE);
-               break;
        case SWITCH_MESSAGE_INDICATE_UNBRIDGE:
                mod_spandsp_indicate_data(session, SWITCH_FALSE, SWITCH_TRUE);
                break;
index 4244c1a51991a8db2465092cca918105f0b8c3fa..6b414924e2b58fec39afafa8f42ce55ca20a08c1 100644 (file)
@@ -363,7 +363,7 @@ int udptl_rx_packet(udptl_state_t *s, const uint8_t buf[], int len)
 
 int udptl_build_packet(udptl_state_t *s, uint8_t buf[], const uint8_t msg[], int msg_len)
 {
-       uint8_t fec[LOCAL_FAX_MAX_DATAGRAM];
+       uint8_t fec[LOCAL_FAX_MAX_DATAGRAM] = { 0 };
        int i;
        int j;
        int seq;