[FFmpeg-devel] [PATCH 2/4] avfiltergraph: Properly handle memory allocation failure

Michael Niedermayer michaelni at gmx.at
Fri Oct 25 13:15:26 CEST 2013


On Tue, Oct 22, 2013 at 09:33:57PM +0100, Derek Buitenhuis wrote:
> Signed-off-by: Derek Buitenhuis <derek.buitenhuis at gmail.com>
> ---
>  libavfilter/avfiltergraph.c | 41 ++++++++++++++++++++++++++++++++---------
>  1 file changed, 32 insertions(+), 9 deletions(-)

[...]

> @@ -456,17 +469,27 @@ static int query_formats(AVFilterGraph *graph, AVClass *log_ctx)
>                  continue;
>
>              if (link->in_formats != link->out_formats
> -                && link->in_formats && link->out_formats)
> -                if (!can_merge_formats(link->in_formats, link->out_formats,
> -                                      link->type, 0))
> -                    convert_needed = 1;
> +                && link->in_formats && link->out_formats) {
> +
> +                ret = can_merge_formats(link->in_formats, link->out_formats,
> +                                        link->type, 0);
> +                if (ret < 0)
> +                    return ret;
> +
> +                convert_needed = !ret;
> +            }
>              if (link->type == AVMEDIA_TYPE_AUDIO) {
>                  if (link->in_samplerates != link->out_samplerates
> -                    && link->in_samplerates && link->out_samplerates)
> -                    if (!can_merge_formats(link->in_samplerates,
> -                                           link->out_samplerates,
> -                                           0, 1))
> -                        convert_needed = 1;
> +                    && link->in_samplerates && link->out_samplerates) {
> +
> +                    ret = can_merge_formats(link->in_samplerates,
> +                                            link->out_samplerates,
> +                                            0, 1);
> +                    if (ret < 0)
> +                        return ret;
> +
> +                    convert_needed = !ret;
> +                }
>              }

treating failure equal to "needing to convert" should be safe and
simpler


[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

I do not agree with what you have to say, but I'll defend to the death your
right to say it. -- Voltaire
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20131025/d65fa80b/attachment.asc>


More information about the ffmpeg-devel mailing list