@@ -720,7 +720,12 @@ static pj_status_t op_remove_port(pjmedia_vid_conf *vid_conf,
720720    vconf_port  * cport  =  vid_conf -> ports [slot ];
721721    pj_status_t  status ;
722722
723-     pj_assert (cport );
723+     /* Port must be valid. */ 
724+     if  (!cport ) {
725+         PJ_PERROR (3 , (THIS_FILE , PJ_EINVAL ,
726+                       "Failed removing port %d, invalid video port" , slot ));
727+         return  PJ_EINVAL ;
728+     }
724729
725730    /* Disconnect slot -> listeners */ 
726731    while  (cport -> listener_cnt ) {
@@ -937,12 +942,13 @@ static pj_status_t op_connect_ports(pjmedia_vid_conf *vid_conf,
937942    sink_slot  =  prm -> connect_ports .sink ;
938943    src_port  =  vid_conf -> ports [src_slot ];
939944    dst_port  =  vid_conf -> ports [sink_slot ];
940-     pj_assert (src_port  &&  src_port -> port  &&  src_port -> port -> get_frame );
941-     pj_assert (dst_port  &&  dst_port -> port  &&  dst_port -> port -> put_frame );
942945
943-     if  (!src_port  ||  !dst_port ) {
946+     if  (!src_port  ||  !dst_port  || 
947+         !src_port -> port  ||  !dst_port -> port  || 
948+         !src_port -> port -> get_frame  ||  !dst_port -> port -> put_frame )
949+     {
944950        PJ_PERROR (3 , (THIS_FILE , PJ_EINVAL ,
945-                       "Failed connecting %d->%d, make sure  video ports are valid " ,
951+                       "Failed connecting %d->%d, invalid  video ports" ,
946952                      src_slot , sink_slot ));
947953        return  PJ_EINVAL ;
948954    }
@@ -1049,7 +1055,12 @@ static pj_status_t op_disconnect_ports(pjmedia_vid_conf *vid_conf,
10491055    sink_slot  =  prm -> disconnect_ports .sink ;
10501056    src_port  =  vid_conf -> ports [src_slot ];
10511057    dst_port  =  vid_conf -> ports [sink_slot ];
1052-     pj_assert (src_port  &&  dst_port );
1058+     if  (!src_port  ||  !dst_port ) {
1059+         PJ_PERROR (3 , (THIS_FILE , PJ_EINVAL ,
1060+                       "Failed disconnecting %d->%d, invalid video ports" ,
1061+                       src_slot , sink_slot ));
1062+         return  PJ_EINVAL ;
1063+     }
10531064
10541065    /* Check if connection has been made */ 
10551066    for  (i = 0 ; i < src_port -> listener_cnt ; ++ i ) {
@@ -1064,6 +1075,7 @@ static pj_status_t op_disconnect_ports(pjmedia_vid_conf *vid_conf,
10641075    if  (i  ==  src_port -> listener_cnt  ||  j  ==  dst_port -> transmitter_cnt )
10651076        return  PJ_EINVAL ;
10661077
1078+     /* Sanity check: the number of listeners and transmitters. */ 
10671079    pj_assert (src_port -> listener_cnt  >  0  &&  
10681080              src_port -> listener_cnt  <  vid_conf -> opt .max_slot_cnt );
10691081    pj_assert (dst_port -> transmitter_cnt  >  0  &&  
@@ -1658,7 +1670,11 @@ static pj_status_t op_update_port(pjmedia_vid_conf *vid_conf,
16581670    pjmedia_format  * new_fmt ;
16591671
16601672    /* Port must be valid. */ 
1661-     pj_assert (cport );
1673+     if  (!cport ) {
1674+         PJ_PERROR (3 , (THIS_FILE , PJ_EINVAL ,
1675+                       "Failed updating port %d, invalid video port" , slot ));
1676+         return  PJ_EINVAL ;
1677+     }
16621678
16631679    /* Get the old & new formats */ 
16641680    old_fmt  =  & cport -> format ;
0 commit comments