[FFmpeg-devel] [PATCH] avformat/aiffdec: only read codec tag when there is space in header
Reimar Döffinger
Reimar.Doeffinger at gmx.de
Tue Jan 6 11:57:56 CET 2015
On 04.01.2015, at 22:44, Peter Ross <pross at xvid.org> wrote:
> Signed-off-by: Peter Ross <pross at xvid.org>
> ---
> Revised patch. Now passes FATE.
>
> libavformat/aiffdec.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/libavformat/aiffdec.c b/libavformat/aiffdec.c
> index 91ef2a4..8dbed32 100644
> --- a/libavformat/aiffdec.c
> +++ b/libavformat/aiffdec.c
> @@ -116,10 +116,12 @@ static unsigned int get_aiff_header(AVFormatContext *s, int size,
> size -= 18;
>
> /* get codec id for AIFF-C */
> - if (version == AIFF_C_VERSION1) {
> + if (version == AIFF_C_VERSION1 && size >= 4) {
> codec->codec_tag = avio_rl32(pb);
> codec->codec_id = ff_codec_get_id(ff_codec_aiff_tags, codec->codec_tag);
> size -= 4;
> + } else {
> + version = AIFF;
If we were to add a 3rd version, like this it would always the overridden to AIFF here, which seems not very good to me.
Also nit: wouldn't this in be more readable the other way round anyway while solving that concern? At least I think having one-liners in the if instead of the else part is better, though some people say you should put the less common path in the else (though strictly speaking the else isn't even necessary with flipped order).
if (size < 4) {
version = AIFF;
} else if (....) {
}
More information about the ffmpeg-devel
mailing list