1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-11-21 10:55:51 +02:00

lavu/ffmpeg_opt: Check return value of avcodec_find_encoder().

Prevents a segfault if a stream featuring a known but unavailable codec (like external lib codec) should be opened.

Bug found by: Jonas Geistert <j.geistert@yahoo.de>

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
Thilo Borgmann 2014-09-25 16:10:58 +02:00 committed by Michael Niedermayer
parent ce6e46be72
commit e113692c89

View File

@ -1623,6 +1623,10 @@ static int read_ffserver_streams(OptionsContext *o, AVFormatContext *s, const ch
AVCodecContext *avctx; AVCodecContext *avctx;
codec = avcodec_find_encoder(ic->streams[i]->codec->codec_id); codec = avcodec_find_encoder(ic->streams[i]->codec->codec_id);
if (!codec) {
av_log(s, AV_LOG_ERROR, "no encoder found for codec id %i\n", ic->streams[i]->codec->codec_id);
return AVERROR(EINVAL);
}
ost = new_output_stream(o, s, codec->type, -1); ost = new_output_stream(o, s, codec->type, -1);
st = ost->st; st = ost->st;
avctx = st->codec; avctx = st->codec;