[FFmpeg-devel] [PATCH 3/3] avformat/webpenc: Check seeks

Andreas Rheinhardt andreas.rheinhardt at outlook.com
Sun Apr 11 03:43:02 EEST 2021


When writing the trailer, the WebP muxer unconditionally seeks back
to the front to update some elements. Yet this doesn't work if
the seek failed, so check for this.

(This has been mentioned in ticket #9179.)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
---
 libavformat/webpenc.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/libavformat/webpenc.c b/libavformat/webpenc.c
index 3962986c32..a24920d181 100644
--- a/libavformat/webpenc.c
+++ b/libavformat/webpenc.c
@@ -174,8 +174,8 @@ static int webp_write_trailer(AVFormatContext *s)
 
     if (w->using_webp_anim_encoder) {
         if ((w->frame_count > 1) && w->loop) {  // Write loop count.
-            avio_seek(s->pb, 42, SEEK_SET);
-            avio_wl16(s->pb, w->loop);
+            if (avio_seek(s->pb, 42, SEEK_SET) == 42)
+                avio_wl16(s->pb, w->loop);
         }
     } else {
         int ret;
@@ -183,8 +183,8 @@ static int webp_write_trailer(AVFormatContext *s)
             return ret;
 
         filesize = avio_tell(s->pb);
-        avio_seek(s->pb, 4, SEEK_SET);
-        avio_wl32(s->pb, filesize - 8);
+        if (avio_seek(s->pb, 4, SEEK_SET) == 4)
+            avio_wl32(s->pb, filesize - 8);
         // Note: without the following, avio only writes 8 bytes to the file.
         avio_seek(s->pb, filesize, SEEK_SET);
     }
-- 
2.27.0



More information about the ffmpeg-devel mailing list