diff --git a/libs/freetdm/src/ftdm_io.c b/libs/freetdm/src/ftdm_io.c index 249d8580b5..ef290964d4 100644 --- a/libs/freetdm/src/ftdm_io.c +++ b/libs/freetdm/src/ftdm_io.c @@ -128,8 +128,15 @@ static void write_chan_io_dump(ftdm_io_dump_t *dump, char *dataptr, int dlen) static void dump_chan_io_to_file(ftdm_channel_t *fchan, ftdm_io_dump_t *dump, FILE *file) { /* write the saved audio buffer */ - size_t rc = 0; - size_t towrite = dump->size - dump->windex; + ftdm_size_t rc = 0; + ftdm_size_t towrite = 0; + + if (!dump->buffer) { + return; + } + + towrite = dump->size - dump->windex; + if (dump->wrapped) { rc = fwrite(&dump->buffer[dump->windex], 1, towrite, file); if (rc != towrite) { @@ -2821,6 +2828,10 @@ FT_DECLARE(ftdm_status_t) ftdm_channel_command(ftdm_channel_t *ftdmchan, ftdm_co if (!obj) { GOTO_STATUS(done, FTDM_FAIL); } + if (!ftdmchan->rxdump.buffer) { + ftdm_log_chan(ftdmchan, FTDM_LOG_WARNING, "Not dumped input to file %p, input dump is not enabled\n", obj); + GOTO_STATUS(done, FTDM_FAIL); + } dump_chan_io_to_file(ftdmchan, &ftdmchan->rxdump, obj); ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Dumped input of size %d to file %p\n", ftdmchan->rxdump.size, obj); GOTO_STATUS(done, FTDM_SUCCESS); @@ -2833,6 +2844,10 @@ FT_DECLARE(ftdm_status_t) ftdm_channel_command(ftdm_channel_t *ftdmchan, ftdm_co if (!obj) { GOTO_STATUS(done, FTDM_FAIL); } + if (!ftdmchan->txdump.buffer) { + ftdm_log_chan(ftdmchan, FTDM_LOG_WARNING, "Not dumped output to file %p, output dump is not enabled\n", obj); + GOTO_STATUS(done, FTDM_FAIL); + } dump_chan_io_to_file(ftdmchan, &ftdmchan->txdump, obj); ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Dumped input of size %zd to file %p\n", ftdmchan->txdump.size, obj); GOTO_STATUS(done, FTDM_SUCCESS); diff --git a/libs/freetdm/src/ftmod/ftmod_r2/ftmod_r2.c b/libs/freetdm/src/ftmod/ftmod_r2/ftmod_r2.c index ab85d2b4d6..37070c45a1 100644 --- a/libs/freetdm/src/ftmod/ftmod_r2/ftmod_r2.c +++ b/libs/freetdm/src/ftmod/ftmod_r2/ftmod_r2.c @@ -29,6 +29,11 @@ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * Contributors: + * + * Arnaldo Pereira + * */ #ifdef __linux__