diff --git a/src/switch_apr.c b/src/switch_apr.c index bb77e9f012..6a92d3341b 100644 --- a/src/switch_apr.c +++ b/src/switch_apr.c @@ -476,7 +476,11 @@ SWITCH_DECLARE(switch_status_t) switch_dir_open(switch_dir_t **new_dir, const ch switch_status_t status; switch_dir_t *dir = malloc(sizeof(*dir)); - switch_assert(dir); + if (!dir) { + *new_dir = NULL; + return SWITCH_STATUS_FALSE; + } + memset(dir, 0, sizeof(*dir)); if ((status = apr_dir_open(&(dir->dir_handle), dirname, pool)) == APR_SUCCESS) { *new_dir = dir; @@ -813,14 +817,19 @@ SWITCH_DECLARE(int) switch_vasprintf(char **ret, const char *fmt, va_list ap) int len; size_t buflen; va_list ap2; + char *tmp = NULL; #ifdef _MSC_VER +#if _MSC_VER >= 1500 + /* hack for incorrect assumption in msvc header files for code analysis */ + __analysis_assume(tmp); +#endif ap2 = ap; #else va_copy(ap2, ap); #endif - len = vsnprintf(NULL, 0, fmt, ap2); + len = vsnprintf(tmp, 0, fmt, ap2); if (len > 0 && (buf = malloc((buflen = (size_t) (len + 1)))) != NULL) { len = vsnprintf(buf, buflen, fmt, ap); diff --git a/src/switch_ivr_async.c b/src/switch_ivr_async.c index 2a33dc8893..c12b03620e 100644 --- a/src/switch_ivr_async.c +++ b/src/switch_ivr_async.c @@ -120,25 +120,25 @@ static switch_bool_t displace_callback(switch_media_bug_t *bug, void *user_data, break; case SWITCH_ABC_TYPE_READ_REPLACE: { - switch_frame_t *frame = switch_core_media_bug_get_read_replace_frame(bug); + switch_frame_t *rframe = switch_core_media_bug_get_read_replace_frame(bug); if (dh && !dh->mux) { - memset(frame->data, 255, frame->datalen); + memset(rframe->data, 255, rframe->datalen); } - switch_core_media_bug_set_read_replace_frame(bug, frame); + switch_core_media_bug_set_read_replace_frame(bug, rframe); } break; case SWITCH_ABC_TYPE_WRITE_REPLACE: if (dh) { - switch_frame_t *frame = NULL; + switch_frame_t *rframe = NULL; switch_size_t len; switch_status_t st; - frame = switch_core_media_bug_get_write_replace_frame(bug); - len = frame->samples; + rframe = switch_core_media_bug_get_write_replace_frame(bug); + len = rframe->samples; if (dh->mux) { int16_t buf[1024]; - int16_t *fp = frame->data; + int16_t *fp = rframe->data; uint32_t x; st = switch_core_file_read(&dh->fh, buf, &len); @@ -149,16 +149,16 @@ static switch_bool_t displace_callback(switch_media_bug_t *bug, void *user_data, fp[x] = (int16_t) mixed; } } else { - st = switch_core_file_read(&dh->fh, frame->data, &len); - frame->samples = (uint32_t) len; - frame->datalen = frame->samples * 2; + st = switch_core_file_read(&dh->fh, rframe->data, &len); + rframe->samples = (uint32_t) len; + rframe->datalen = rframe->samples * 2; } if (st != SWITCH_STATUS_SUCCESS || len == 0) { return SWITCH_FALSE; } - switch_core_media_bug_set_write_replace_frame(bug, frame); + switch_core_media_bug_set_write_replace_frame(bug, rframe); } break; case SWITCH_ABC_TYPE_WRITE: @@ -358,18 +358,18 @@ static switch_bool_t eavesdrop_callback(switch_media_bug_t *bug, void *user_data case SWITCH_ABC_TYPE_READ_REPLACE: { if (switch_test_flag(ep, ED_MUX_READ)) { - switch_frame_t *frame = switch_core_media_bug_get_read_replace_frame(bug); + switch_frame_t *rframe = switch_core_media_bug_get_read_replace_frame(bug); - if (switch_buffer_inuse(ep->r_buffer) >= frame->datalen) { + if (switch_buffer_inuse(ep->r_buffer) >= rframe->datalen) { uint32_t bytes; switch_buffer_lock(ep->r_buffer); - bytes = (uint32_t) switch_buffer_read(ep->r_buffer, data, frame->datalen); + bytes = (uint32_t) switch_buffer_read(ep->r_buffer, data, rframe->datalen); - frame->datalen = switch_merge_sln(frame->data, frame->samples, (int16_t *)data, bytes / 2) * 2; - frame->samples = frame->datalen / 2; + rframe->datalen = switch_merge_sln(rframe->data, rframe->samples, (int16_t *)data, bytes / 2) * 2; + rframe->samples = rframe->datalen / 2; switch_buffer_unlock(ep->r_buffer); - switch_core_media_bug_set_read_replace_frame(bug, frame); + switch_core_media_bug_set_read_replace_frame(bug, rframe); } } } @@ -378,18 +378,18 @@ static switch_bool_t eavesdrop_callback(switch_media_bug_t *bug, void *user_data case SWITCH_ABC_TYPE_WRITE_REPLACE: { if (switch_test_flag(ep, ED_MUX_WRITE)) { - switch_frame_t *frame = switch_core_media_bug_get_write_replace_frame(bug); + switch_frame_t *rframe = switch_core_media_bug_get_write_replace_frame(bug); - if (switch_buffer_inuse(ep->w_buffer) >= frame->datalen) { + if (switch_buffer_inuse(ep->w_buffer) >= rframe->datalen) { uint32_t bytes; switch_buffer_lock(ep->w_buffer); - bytes = (uint32_t) switch_buffer_read(ep->w_buffer, data, frame->datalen); + bytes = (uint32_t) switch_buffer_read(ep->w_buffer, data, rframe->datalen); - frame->datalen = switch_merge_sln(frame->data, frame->samples, (int16_t *)data, bytes / 2) * 2; - frame->samples = frame->datalen / 2; + rframe->datalen = switch_merge_sln(rframe->data, rframe->samples, (int16_t *)data, bytes / 2) * 2; + rframe->samples = rframe->datalen / 2; switch_buffer_unlock(ep->w_buffer); - switch_core_media_bug_set_write_replace_frame(bug, frame); + switch_core_media_bug_set_write_replace_frame(bug, rframe); } } } diff --git a/src/switch_utils.c b/src/switch_utils.c index ddee0fe183..8d9319aa63 100644 --- a/src/switch_utils.c +++ b/src/switch_utils.c @@ -339,7 +339,9 @@ SWITCH_DECLARE(switch_bool_t) switch_simple_email(const char *to, const char *fr switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unable to execute command: %s\n", buf); } - unlink(filename); + if (unlink(filename) != 0) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "failed to delete file [%s]\n", filename); + } if (file) {