[mod_av] dont leak avformat context in error cases
This commit is contained in:
parent
c4b8f1a8d1
commit
fc8d431879
|
@ -1157,8 +1157,6 @@ static switch_status_t open_input_file(av_file_context_t *context, switch_file_h
|
||||||
if ((error = avformat_open_input(&context->fc, filename, NULL, NULL)) < 0) {
|
if ((error = avformat_open_input(&context->fc, filename, NULL, NULL)) < 0) {
|
||||||
char ebuf[255] = "";
|
char ebuf[255] = "";
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Could not open input file '%s' (error '%s')\n", filename, get_error_text(error, ebuf, sizeof(ebuf)));
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Could not open input file '%s' (error '%s')\n", filename, get_error_text(error, ebuf, sizeof(ebuf)));
|
||||||
avformat_free_context(context->fc);
|
|
||||||
context->fc = NULL;
|
|
||||||
switch_goto_status(SWITCH_STATUS_FALSE, err);
|
switch_goto_status(SWITCH_STATUS_FALSE, err);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1334,6 +1332,11 @@ GCC_DIAG_ON(deprecated-declarations)
|
||||||
return status;
|
return status;
|
||||||
|
|
||||||
err:
|
err:
|
||||||
|
if (context->fc) {
|
||||||
|
avformat_free_context(context->fc);
|
||||||
|
context->fc = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
if (context->has_video) close_stream(context->fc, &context->video_st);
|
if (context->has_video) close_stream(context->fc, &context->video_st);
|
||||||
if (context->has_audio) close_stream(context->fc, &context->audio_st);
|
if (context->has_audio) close_stream(context->fc, &context->audio_st);
|
||||||
|
|
Loading…
Reference in New Issue