[FFmpeg-devel] [PATCH 4/5] avfilter/formats: proper error handling in ff_set_common_*() functions
Clément Bœsch
u at pkh.me
Sun Mar 15 15:11:14 CET 2015
On Sun, Mar 15, 2015 at 03:07:16PM +0100, Stefano Sabatini wrote:
> On date Sunday 2015-03-15 14:24:29 +0100, Clément Bœsch encoded:
> > ---
> > libavfilter/formats.c | 45 ++++++++++++++++++++++++++++++++-------------
> > libavfilter/formats.h | 10 +++++-----
> > 2 files changed, 37 insertions(+), 18 deletions(-)
> >
> > diff --git a/libavfilter/formats.c b/libavfilter/formats.c
> > index 6393416..4f9773b 100644
> > --- a/libavfilter/formats.c
> > +++ b/libavfilter/formats.c
> > @@ -401,7 +401,12 @@ AVFilterChannelLayouts *ff_all_channel_counts(void)
> > }
> >
> > #define FORMATS_REF(f, ref) \
> > - void *tmp = av_realloc_array(f->refs, sizeof(*f->refs), f->refcount + 1); \
> > + void *tmp; \
> > + \
> > + if (!ref) \
> > + return AVERROR_BUG; \
>
> I'd prefer to crash or assert here, assuming the function doesn't
> assume NULL, same below.
>
In the current state, these functions could be called with a NULL
parameter. Random examples:
libavfilter/src_movie.c: ff_formats_ref(ff_make_format_list(list), &outlink->in_formats);
libavfilter/src_movie.c: ff_formats_ref(ff_make_format_list(list), &outlink->in_samplerates);
libavfilter/vf_extractplanes.c: ff_formats_ref(ff_make_format_list(in_pixfmts), &ctx->inputs[0]->out_formats);
libavfilter/vf_extractplanes.c: ff_formats_ref(ff_make_format_list(out_pixfmts), &ctx->outputs[i]->in_formats);
So I'd better not do that.
> (Unrelated note: "bug" is a silly term, "defect" is more proper - I'm
> with Dijkstra here).
>
> [...]
>
> LGTM otherwise, thanks.
--
Clément B.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 473 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20150315/88f700a1/attachment.asc>
More information about the ffmpeg-devel
mailing list