]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
Fix span index issues
authorMathieu Rene <mrene@avgs.ca>
Tue, 24 Feb 2009 21:27:35 +0000 (21:27 +0000)
committerMathieu Rene <mrene@avgs.ca>
Tue, 24 Feb 2009 21:27:35 +0000 (21:27 +0000)
git-svn-id: http://svn.openzap.org/svn/openzap/trunk@670 a93c3328-9c30-0410-af19-c9cd2b2d52af

libs/openzap/src/zap_io.c

index daaf1061cb9dcbc254d5b76ba8cb96f48871bf5c..e83bcf37596d6b7657038125aa1fcbaabc111e9d 100644 (file)
@@ -839,7 +839,7 @@ zap_status_t zap_channel_open_any(uint32_t span_id, zap_direction_t direction, z
        uint32_t span_max;
 
        if (span_id) {
-               if (span_id >= globals.span_index) {
+               if (span_id > globals.span_index || !globals.span[span_id]) {
                        zap_log(ZAP_LOG_CRIT, "SPAN NOT DEFINED!\n");
                        *zchan = NULL;
             return ZAP_FAIL;
@@ -1047,9 +1047,16 @@ zap_status_t zap_channel_open(uint32_t span_id, uint32_t chan_id, zap_channel_t
 
        if (span_id < ZAP_MAX_SPANS_INTERFACE && chan_id < ZAP_MAX_CHANNELS_SPAN) {
                zap_channel_t *check;
+               
+               if (span_id > globals.span_index || !globals.span[span_id]) {
+                       zap_log(ZAP_LOG_ERROR, "SPAN NOT DEFINED!\n");
+                       *zchan = NULL;
+                       goto done;
+               }
 
                if (globals.spans[span_id]->channel_request) {
                        zap_log(ZAP_LOG_ERROR, "Individual channel selection not implemented on this span.\n");
+                       *zchan = NULL;
                        goto done;
                }
                
@@ -1057,6 +1064,7 @@ zap_status_t zap_channel_open(uint32_t span_id, uint32_t chan_id, zap_channel_t
 
                if (zap_test_flag(check, ZAP_CHANNEL_SUSPENDED) || 
                        !zap_test_flag(check, ZAP_CHANNEL_READY) || (status = zap_mutex_trylock(check->mutex)) != ZAP_SUCCESS) {
+                       *zchan = NULL;
                        goto done;
                }