[vlc-devel] [PATCH 1/2] mp4: Return an error if there are no attachments

Rémi Denis-Courmont remi at remlab.net
Mon Nov 23 21:18:22 CET 2020


Le lundi 23 novembre 2020, 15:53:23 EET Hugo Beauzée-Luyssen a écrit :
> Instead of allocating an empty array that wouldn't be freed by the core

Is there a stated rule anywhere that attachments must be non-zero? And if 
there is, there should probably be an assertion. If there is not, then this 
seems like a bug in the caller (though this patch is still potentially valid).

> ---
>  modules/demux/mp4/mp4.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/modules/demux/mp4/mp4.c b/modules/demux/mp4/mp4.c
> index 30cff828c1..4ccfd88d82 100644
> --- a/modules/demux/mp4/mp4.c
> +++ b/modules/demux/mp4/mp4.c
> @@ -2059,6 +2059,8 @@ static int Control( demux_t *p_demux, int i_query,
> va_list args )
> 
>              if( p_sys->i_attachments == -1 )
>                  p_sys->i_attachments = MP4_GetAttachments( p_sys->p_root,
> &p_sys->pp_attachments ); +            if( !p_sys->i_attachments )
> +                return VLC_EGENERIC;
>              *ppp_attach = calloc( p_sys->i_attachments, sizeof(**ppp_attach
> ) ); if( !*ppp_attach )
>                  return VLC_ENOMEM;


-- 
Rémi Denis-Courmont




More information about the vlc-devel mailing list