Message ID | 20211215024728.85590-1-young_chelsea@163.com |
---|---|
State | Accepted |
Commit | a4580bf95985e033eb8857156db3670eeec48131 |
Headers | show |
Series | [FFmpeg-devel,v5] fftools/cmdutils: Avoid crash when opts could not be allocated | expand |
Context | Check | Description |
---|---|---|
andriy/make_x86 | success | Make finished |
andriy/make_fate_x86 | success | Make fate finished |
andriy/make_ppc | success | Make finished |
andriy/make_fate_ppc | success | Make fate finished |
Yu Yang: > From: Yu Yang <yuyang14@kuaishou.com> > > If 'opts' could not be allocated, exiting the program to avoid crash when release it. > > Reported-by: TOTE Robot <oslab@tsinghua.edu.cn> > Signed-off-by: Yu Yang <yuyang14@kuaishou.com> > --- > fftools/cmdutils.c | 2 +- > fftools/cmdutils.h | 4 ++-- > 2 files changed, 3 insertions(+), 3 deletions(-) > > diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c > index 3c8e5a82cd..882584e9c2 100644 > --- a/fftools/cmdutils.c > +++ b/fftools/cmdutils.c > @@ -2187,7 +2187,7 @@ AVDictionary **setup_find_stream_info_opts(AVFormatContext *s, > if (!opts) { > av_log(NULL, AV_LOG_ERROR, > "Could not alloc memory for stream options.\n"); > - return NULL; > + exit_program(1); > } > for (i = 0; i < s->nb_streams; i++) > opts[i] = filter_codec_opts(codec_opts, s->streams[i]->codecpar->codec_id, > diff --git a/fftools/cmdutils.h b/fftools/cmdutils.h > index 82cda208be..50eed9b13a 100644 > --- a/fftools/cmdutils.h > +++ b/fftools/cmdutils.h > @@ -430,8 +430,8 @@ AVDictionary *filter_codec_opts(AVDictionary *opts, enum AVCodecID codec_id, > * Each dictionary will contain the options from codec_opts which can > * be applied to the corresponding stream codec context. > * > - * @return pointer to the created array of dictionaries, NULL if it > - * cannot be created > + * @return pointer to the created array of dictionaries. > + * Calls exit() on failure. > */ > AVDictionary **setup_find_stream_info_opts(AVFormatContext *s, > AVDictionary *codec_opts); > Applied. Thanks. - Andreas
diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c index 3c8e5a82cd..882584e9c2 100644 --- a/fftools/cmdutils.c +++ b/fftools/cmdutils.c @@ -2187,7 +2187,7 @@ AVDictionary **setup_find_stream_info_opts(AVFormatContext *s, if (!opts) { av_log(NULL, AV_LOG_ERROR, "Could not alloc memory for stream options.\n"); - return NULL; + exit_program(1); } for (i = 0; i < s->nb_streams; i++) opts[i] = filter_codec_opts(codec_opts, s->streams[i]->codecpar->codec_id, diff --git a/fftools/cmdutils.h b/fftools/cmdutils.h index 82cda208be..50eed9b13a 100644 --- a/fftools/cmdutils.h +++ b/fftools/cmdutils.h @@ -430,8 +430,8 @@ AVDictionary *filter_codec_opts(AVDictionary *opts, enum AVCodecID codec_id, * Each dictionary will contain the options from codec_opts which can * be applied to the corresponding stream codec context. * - * @return pointer to the created array of dictionaries, NULL if it - * cannot be created + * @return pointer to the created array of dictionaries. + * Calls exit() on failure. */ AVDictionary **setup_find_stream_info_opts(AVFormatContext *s, AVDictionary *codec_opts);