]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
[mod_vlc] scan-build: multiple dereferences of a null pointer 449/head
authorDragos Oancea <dragos@signalwire.com>
Thu, 27 Feb 2020 11:48:56 +0000 (11:48 +0000)
committerDragos Oancea <dragos@signalwire.com>
Thu, 27 Feb 2020 11:50:30 +0000 (11:50 +0000)
src/mod/formats/mod_vlc/mod_vlc.c

index 48df3c458a616d7446891bdee5aa863b7927b7c5..00a71ce58dbc90aa118e415902ef11d19e0440d2 100644 (file)
@@ -274,6 +274,8 @@ static void vlc_media_av_state_callback(const libvlc_event_t * event, void * dat
                if (!(vcontext = acontext->vcontext)) {
                        return;
                }
+       } else {
+               return;
        }
 
        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Got a libvlc_MediaStateChanged callback. New state: %d\n", new_state);
@@ -357,6 +359,8 @@ void vlc_file_play_audio_callback(void *data, const void *samples, unsigned coun
                if (!(vcontext = acontext->vcontext)) {
                        return;
                }
+       } else {
+               return;
        }
 
        switch_mutex_lock(vcontext->audio_mutex);
@@ -585,14 +589,14 @@ static switch_status_t av_init_handle(switch_file_handle_t *handle, switch_image
        int32_t offset = 250;
        const char *tmp;
     vlc_file_context_t *acontext = handle->private_info;
-       const char * opts[25] = {
-               *vlc_args,
-               switch_core_sprintf(acontext->pool, "--sout=%s", acontext->path)
-       };
+       const char * opts[25] = {0};
        int argc = 2;
        vlc_video_context_t *vcontext;
 
 
+       opts[0] = *vlc_args;
+       if (acontext) opts[1] = switch_core_sprintf(acontext->pool, "--sout=%s", acontext->path);
+
        vcontext = acontext->vcontext;
        pool = acontext->pool;
 
@@ -963,9 +967,11 @@ static switch_status_t vlc_file_av_read(switch_file_handle_t *handle, void *data
                if (!(vcontext = acontext->vcontext)) {
                        return SWITCH_STATUS_FALSE;
                }
+       } else {
+               return SWITCH_STATUS_FALSE;
        }
 
-       if (vcontext->err) {
+       if (vcontext && vcontext->err) {
                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "VLC ended\n");
                return SWITCH_STATUS_GENERR;
        }
@@ -1122,6 +1128,8 @@ static switch_status_t vlc_file_read_video(switch_file_handle_t *handle, switch_
                if (!(vcontext = acontext->vcontext)) {
                        return SWITCH_STATUS_FALSE;
                }
+       } else {
+               return SWITCH_STATUS_FALSE;
        }
 
        if (vcontext->err) {