]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-7762: [mod_av] handle buffer allocation failures of large buffers
authorMichael Jerris <mike@jerris.com>
Tue, 7 Jul 2015 15:50:07 +0000 (11:50 -0400)
committerMichael Jerris <mike@jerris.com>
Tue, 7 Jul 2015 15:50:07 +0000 (11:50 -0400)
src/mod/applications/mod_av/avformat.c

index eadf20ea141193823d4e7b47a4c2165ea9b762f6..0723ad9d5dce67159b6e065b615277248d204b77 100644 (file)
@@ -640,6 +640,11 @@ SWITCH_STANDARD_APP(record_av_function)
 
        switch_buffer_create_dynamic(&buffer, 8192, 65536, 0);
 
+       if (!buffer) {
+               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not allocate buffer for %s\n", data);
+               goto end;
+       }
+
        av_register_all();
        mod_avformat_alloc_output_context2(&fc, NULL, format, data);
 
@@ -1365,6 +1370,11 @@ static switch_status_t av_file_open(switch_file_handle_t *handle, const char *pa
 
        switch_buffer_create_dynamic(&context->audio_buffer, 512, 512, 0);
 
+       if (!context->audio_buffer) {
+               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not allocate buffer for %s\n", path);
+               return SWITCH_STATUS_MEMERR;
+       }
+
        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "sample rate: %d, channels: %d\n", handle->samplerate, handle->channels);
 
        av_register_all();