decoder/ffmpeg: free AVFormatContext on error
Fix a memory leak in some code paths.
This commit is contained in:
parent
ca1fc13116
commit
acd3f8cd91
@ -193,12 +193,14 @@ ffmpeg_helper(struct input_stream *input,
|
||||
|
||||
if (av_find_stream_info(format_context)<0) {
|
||||
g_warning("Couldn't find stream info\n");
|
||||
av_close_input_file(format_context);
|
||||
return false;
|
||||
}
|
||||
|
||||
audio_stream = ffmpeg_find_audio_stream(format_context);
|
||||
if (audio_stream == -1) {
|
||||
g_warning("No audio stream inside\n");
|
||||
av_close_input_file(format_context);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -210,11 +212,13 @@ ffmpeg_helper(struct input_stream *input,
|
||||
|
||||
if (!codec) {
|
||||
g_warning("Unsupported audio codec\n");
|
||||
av_close_input_file(format_context);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (avcodec_open(codec_context, codec)<0) {
|
||||
g_warning("Could not open codec\n");
|
||||
av_close_input_file(format_context);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user