[FFmpeg-cvslog] lavf/id3v2: seek back to previous offset if header size is not matched

Matthieu Bouron git at videolan.org
Sun Jan 20 05:07:16 CET 2013


ffmpeg | branch: master | Matthieu Bouron <matthieu.bouron at gmail.com> | Sat Jan 19 13:32:58 2013 +0100| [b3b456b2588f67a152f3035cbc80d349898534c1] | committer: Michael Niedermayer

lavf/id3v2: seek back to previous offset if header size is not matched

Makes ff_id3v2_read reset stream position at the end of ID3 data if the
header size is not matched (caused by an EOF for example).

Current behaviour (without the patch):
    filesize = 400
    id3 data size = 399
    file offset after ff_id3v2_read is 400 instead of 399

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b3b456b2588f67a152f3035cbc80d349898534c1
---

 libavformat/id3v2.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/libavformat/id3v2.c b/libavformat/id3v2.c
index 98f8f9e..2cab5ac 100644
--- a/libavformat/id3v2.c
+++ b/libavformat/id3v2.c
@@ -788,8 +788,10 @@ void ff_id3v2_read(AVFormatContext *s, const char *magic, ID3v2ExtraMeta **extra
         /* save the current offset in case there's nothing to read/skip */
         off = avio_tell(s->pb);
         ret = avio_read(s->pb, buf, ID3v2_HEADER_SIZE);
-        if (ret != ID3v2_HEADER_SIZE)
+        if (ret != ID3v2_HEADER_SIZE) {
+            avio_seek(s->pb, off, SEEK_SET);
             break;
+        }
         found_header = ff_id3v2_match(buf, magic);
         if (found_header) {
             /* parse ID3v2 header */



More information about the ffmpeg-cvslog mailing list