]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
fix OPENZAP-14
authorAnthony Minessale <anthony.minessale@gmail.com>
Wed, 10 Sep 2008 19:27:17 +0000 (19:27 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Wed, 10 Sep 2008 19:27:17 +0000 (19:27 +0000)
git-svn-id: http://svn.openzap.org/svn/openzap/trunk@553 a93c3328-9c30-0410-af19-c9cd2b2d52af

libs/openzap/mod_openzap/mod_openzap.c
libs/openzap/src/zap_io.c

index 00274511792a3508f9ffa7616b7a4ea439f87cfe..9a1ac3423f1ac67172300f37b7d08525b4f7e7d6 100644 (file)
@@ -1824,7 +1824,7 @@ SWITCH_STANDARD_API(oz_function)
                                        int j;
                                        
                                        stream->write_function(stream, "+OK\n");
-                                       for(j = 0; j <= span->chan_count; j++) {
+                                       for(j = 1; j <= span->chan_count; j++) {
                                                dump_chan(span, j, stream);
                                        }
 
index 69b920c3f1e18ea2348382a68a45d01dee180277..864b19ffd1ab71c53b448c6bf4791a07e00a8f60 100644 (file)
@@ -345,7 +345,7 @@ zap_status_t zap_span_close_all(void)
        for(i = 1; i <= globals.span_index; i++) {
                span = globals.spans[i];
                if (zap_test_flag(span, ZAP_SPAN_CONFIGURED)) {
-                       for(j = 0; j <= span->chan_count && span->channels[j]; j++) {
+                       for(j = 1; j <= span->chan_count && span->channels[j]; j++) {
                                zap_channel_destroy(span->channels[j]);
                        }
                } 
@@ -429,6 +429,7 @@ zap_status_t zap_span_add_channel(zap_span_t *span, zap_socket_t sockfd, zap_cha
                                return ZAP_FAIL;
                        }
                        span->channels[span->chan_count] = new_chan;
+                       memset(new_chan, 0, sizeof(*new_chan));
                }
 
                new_chan->type = type;
@@ -869,7 +870,11 @@ zap_status_t zap_channel_open_any(uint32_t span_id, zap_direction_t direction, z
                                }
                        }
                        
-                       check = span->channels[i];
+                       if (!(check = span->channels[i])) {
+                               status = ZAP_FAIL;
+                               zap_mutex_unlock(span->mutex);
+                               goto done;
+                       }
                        
                        if (zap_test_flag(check, ZAP_CHANNEL_READY) && 
                                !zap_test_flag(check, ZAP_CHANNEL_INUSE) &&