[FFmpeg-devel] [PATCH] avfilter/formats: replace non functional av_realloc() check by assert
Clément Bœsch
u at pkh.me
Thu Mar 12 23:15:38 CET 2015
On Thu, Mar 12, 2015 at 11:04:57PM +0100, Michael Niedermayer wrote:
> Simply returning on failure without indicating failure does not work
> it instead crashes later, its better to fail immedeately until the
> failure is handled.
>
> Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
> ---
> libavfilter/formats.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/libavfilter/formats.c b/libavfilter/formats.c
> index f25328c..9e19613 100644
> --- a/libavfilter/formats.c
> +++ b/libavfilter/formats.c
> @@ -416,8 +416,7 @@ AVFilterChannelLayouts *ff_all_channel_counts(void)
> do { \
> *ref = f; \
> f->refs = av_realloc(f->refs, sizeof(*f->refs) * ++f->refcount); \
> - if (!f->refs) \
> - return; \
> + av_assert0(f->refs); \
> f->refs[f->refcount-1] = ref; \
> } while (0)
>
this macro (FORMATS_REF) is used in ff_channel_layouts_ref() and
ff_formats_ref().
Both of these are currently returning void, but both of them are also
private, so there is nothing (AFAICT) that prevents changing their
prototype and making them return int / AVERROR(ENOMEM).
Asserting on the result of an alloc? Yeah, please don't. This sounds
fixable properly without that much more efforts.
--
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/20150312/25b78670/attachment.asc>
More information about the ffmpeg-devel
mailing list