From baee22d71825128f74beb15122cd786f8d89f13f Mon Sep 17 00:00:00 2001 From: Chen Meng <mengchen...@alibaba-inc.com> Date: Tue, 8 Nov 2016 22:58:44 +0800 Subject: [PATCH] Take the error code in return.
--- libavformat/mov.c | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/libavformat/mov.c b/libavformat/mov.c index 388cd1f..c86252c 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -4529,30 +4529,28 @@ static int mov_read_uuid(MOVContext *c, AVIOContext *pb, MOVAtom atom) uint8_t *buffer; size_t len = atom.size - sizeof(uuid); - buffer = av_mallocz(len + 1); - if (!buffer) { - return AVERROR(ENOMEM); - } - if (c->export_xmp) { + buffer = av_mallocz(len + 1); + if (!buffer) { + return AVERROR(ENOMEM); + } ret = avio_read(pb, buffer, len); - if (ret != len) { + if (ret < 0) { + av_free(buffer); + return ret; + } else if (ret != len) { av_free(buffer); return AVERROR_INVALIDDATA; } - } else { - // skip all uuid atom, which makes it fast for long uuid-xmp file - ret = avio_seek(pb, len, SEEK_CUR); - } - if (ret < 0) { - av_free(buffer); - return ret; - } - if (c->export_xmp) { buffer[len] = '\0'; av_dict_set(&c->fc->metadata, "xmp", buffer, 0); + av_free(buffer); + } else { + // skip all uuid atom, which makes it fast for long uuid-xmp file + ret = avio_seek(pb, len, SEEK_CUR); + if (ret < 0) + return ret; } - av_free(buffer); } return 0; } -- 2.10.2 ------------------------------------------------------------------From:Michael Niedermayer <mich...@niedermayer.cc>Time:2016 Nov 8 (Tue) 20:10To:FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>Subject:Re: [FFmpeg-devel] [PATCH] Making process of uuid-xmp faster. On Tue, Nov 08, 2016 at 04:34:13PM +0800, Chen Meng wrote: > --- > libavformat/mov.c | 15 +++++++++++---- > 1 file changed, 11 insertions(+), 4 deletions(-) > > diff --git a/libavformat/mov.c b/libavformat/mov.c > index f06de06..388cd1f 100644 > --- a/libavformat/mov.c > +++ b/libavformat/mov.c > @@ -4533,13 +4533,20 @@ static int mov_read_uuid(MOVContext *c, AVIOContext >*pb, MOVAtom atom) > if (!buffer) { > return AVERROR(ENOMEM); > } > - ret = avio_read(pb, buffer, len); > + > + if (c->export_xmp) { > + ret = avio_read(pb, buffer, len); > + if (ret != len) { > + av_free(buffer); > + return AVERROR_INVALIDDATA; > + } this looses the error code in ret [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Its not that you shouldnt use gotos but rather that you should write readable code and code with gotos often but not always is less readable _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel