]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
add error checking
authorAnthony Minessale <anthony.minessale@gmail.com>
Sat, 24 Jan 2009 18:11:42 +0000 (18:11 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Sat, 24 Jan 2009 18:11:42 +0000 (18:11 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@11482 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/mod/formats/mod_shout/mod_shout.c
src/switch_core_file.c

index 27bfcc57298fa9af6f05bcd87ebe82a8579fc13e..102a70e20d5d60e0d315ee05d7db7e1e8df83849 100644 (file)
@@ -876,6 +876,10 @@ static switch_status_t shout_file_read(switch_file_handle_t *handle, void *data,
 
        *len = 0;
 
+       if (!context || context->err) {
+               return SWITCH_STATUS_FALSE;
+       }
+
        if (context->fd) {
                rb = decode_fd(context, data, bytes);
        } else {
@@ -923,7 +927,16 @@ static switch_status_t shout_file_write(switch_file_handle_t *handle, void *data
                return SWITCH_STATUS_FALSE;
        }
 
+       if (context->err) {
+               return SWITCH_STATUS_FALSE;
+       }
+
        if (context->shout && !context->shout_init) {
+
+               if (!context->gfp) {
+                       return SWITCH_STATUS_FALSE;
+               }
+
                context->shout_init++;
                if (shout_open(context->shout) != SHOUTERR_SUCCESS) {
                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error opening stream: %s\n", shout_get_error(context->shout));
index 02cf50353839552933c3c3e1c4fe9d795670dd4d..0c04c4c2686584d7087cae3cf62e434fc4ac037b 100644 (file)
@@ -45,6 +45,11 @@ SWITCH_DECLARE(switch_status_t) switch_core_perform_file_open(const char *file,
        char stream_name[128] = "";
        char *rhs = NULL;
 
+       if (switch_test_flag(fh, SWITCH_FILE_OPEN)) {
+               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Handle already open\n");
+               return SWITCH_STATUS_FALSE;
+       }
+
        if (switch_strlen_zero(file_path)) {
                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid Filename\n");
                return SWITCH_STATUS_FALSE;
@@ -140,6 +145,10 @@ SWITCH_DECLARE(switch_status_t) switch_core_file_read(switch_file_handle_t *fh,
        switch_assert(fh != NULL);
        switch_assert(fh->file_interface != NULL);
 
+       if (!switch_test_flag(fh, SWITCH_FILE_OPEN)) {
+               return SWITCH_STATUS_FALSE;
+       }
+
  top:
 
        if (fh->buffer && switch_buffer_inuse(fh->buffer) >= *len * 2) {
@@ -253,6 +262,10 @@ SWITCH_DECLARE(switch_status_t) switch_core_file_write(switch_file_handle_t *fh,
        switch_assert(fh != NULL);
        switch_assert(fh->file_interface != NULL);
 
+       if (!switch_test_flag(fh, SWITCH_FILE_OPEN)) {
+               return SWITCH_STATUS_FALSE;
+       }
+
        if (!fh->file_interface->file_write) {
                return SWITCH_STATUS_FALSE;
        }