From d32926db7f4224305a08510c3adc2a3467b3ab2f Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Wed, 12 Feb 2014 15:51:38 +0100 Subject: [PATCH] avformat/riff: return error code from ff_get_guid() Signed-off-by: Michael Niedermayer --- libavformat/riff.h | 2 +- libavformat/riffdec.c | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/libavformat/riff.h b/libavformat/riff.h index b59c6065a0..dba38034e9 100644 --- a/libavformat/riff.h +++ b/libavformat/riff.h @@ -91,7 +91,7 @@ static av_always_inline int ff_guidcmp(const void *g1, const void *g2) return memcmp(g1, g2, sizeof(ff_asf_guid)); } -void ff_get_guid(AVIOContext *s, ff_asf_guid *g); +int ff_get_guid(AVIOContext *s, ff_asf_guid *g); void ff_put_guid(AVIOContext *s, const ff_asf_guid *g); const ff_asf_guid *get_codec_guid(enum AVCodecID id, const AVCodecGuid *av_guid); diff --git a/libavformat/riffdec.c b/libavformat/riffdec.c index c1e9ec1532..48c9a941b7 100644 --- a/libavformat/riffdec.c +++ b/libavformat/riffdec.c @@ -29,11 +29,14 @@ #include "avio_internal.h" #include "riff.h" -void ff_get_guid(AVIOContext *s, ff_asf_guid *g) +int ff_get_guid(AVIOContext *s, ff_asf_guid *g) { av_assert0(sizeof(*g) == 16); //compiler will optimize this out - if (avio_read(s, *g, sizeof(*g)) < (int)sizeof(*g)) + if (avio_read(s, *g, sizeof(*g)) < (int)sizeof(*g)) { memset(*g, 0, sizeof(*g)); + return AVERROR_INVALIDDATA; + } + return 0; } enum AVCodecID ff_codec_guid_get_id(const AVCodecGuid *guids, ff_asf_guid guid)