]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
[mod_verto] Coverity fixes
authorDragos Oancea <dragos@signalwire.com>
Mon, 12 Jun 2023 14:25:37 +0000 (17:25 +0300)
committerGitHub <noreply@github.com>
Mon, 12 Jun 2023 14:25:37 +0000 (17:25 +0300)
[mod_verto] coverity CID 1468439 (Dereference after null check)
[mod_verto] coverity CID 1294451 (Dereference before null check)
[mod_verto] coverity CID 1468443 (Logically dead code)

src/mod/endpoints/mod_verto/mod_verto.c

index 38a3bc302a0dc1ca0c53d201c7628a08f6a10ca9..8920de7e02cb5312ab9d5ed3ccdcb9a708f975a1 100644 (file)
@@ -836,7 +836,7 @@ static void set_perm(const char *str, switch_event_t **event, switch_bool_t add)
                switch_event_create(event, SWITCH_EVENT_REQUEST_PARAMS);
        }
        
-       if (!zstr(str)) {
+       if (!zstr(str) && event && *event) {
                edup = strdup(str);
                switch_assert(edup);
 
@@ -1059,7 +1059,7 @@ static switch_bool_t check_auth(jsock_t *jsock, cJSON *params, int *code, char *
                        *code = CODE_AUTH_FAILED;
                        switch_snprintf(message, mlen, "Login Incorrect");
                        login_fire_custom_event(jsock, params, 0, "Login Incorrect");
-                       switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Login incorrect for user: %s domain: %s\n", id, domain ? domain : "N/A");
+                       switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Login incorrect for user: %s domain: %s\n", id, domain);
                } else {
                        switch_xml_t x_param, x_params;
                        const char *use_passwd = NULL, *verto_context = NULL, *verto_dialplan = NULL;
@@ -3954,7 +3954,7 @@ static switch_bool_t verto__invite_func(const char *method, cJSON *params, jsock
        cJSON *obj = cJSON_CreateObject(), *vobj = NULL, *dedEnc = NULL, *mirrorInput, *bandwidth = NULL, *canvas = NULL;
        switch_core_session_t *session = NULL;
        switch_channel_t *channel;
-       switch_event_t *var_event;
+       switch_event_t *var_event = NULL;
        switch_call_cause_t reason = SWITCH_CAUSE_INVALID_MSG_UNSPECIFIED, cancel_cause = 0;
        switch_caller_profile_t *caller_profile;
        int err = 0;
@@ -4756,14 +4756,12 @@ static int start_jsock(verto_profile_t *profile, ks_socket_t sock, int family)
 
  error:
 
-       if (jsock) {
-               if (jsock->client_socket != KS_SOCK_INVALID) {
-                       close_socket(&jsock->client_socket);
-               }
-
-               switch_core_destroy_memory_pool(&pool);
+       if (jsock->client_socket != KS_SOCK_INVALID) {
+               close_socket(&jsock->client_socket);
        }
 
+       switch_core_destroy_memory_pool(&pool);
+
        return -1;
 }