diff mbox

[FFmpeg-devel,1/3] lavf/matroskadec: resync if cluster parsing fails while seeking

Message ID 20171208124536.44946-1-rodger.combs@gmail.com
State Superseded
Headers show

Commit Message

Rodger Combs Dec. 8, 2017, 12:45 p.m. UTC
---
 libavformat/matroskadec.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

Comments

Michael Niedermayer Dec. 9, 2017, 6:09 p.m. UTC | #1
On Fri, Dec 08, 2017 at 06:45:34AM -0600, Rodger Combs wrote:
> ---
>  libavformat/matroskadec.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)

can you add a fate test for this commit or patchset ?

thx

[...]
--
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Dictatorship: All citizens are under surveillance, all their steps and
actions recorded, for the politicians to enforce control.
Democracy: All politicians are under surveillance, all their steps and
actions recorded, for the citizens to enforce control.
diff mbox

Patch

diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index 496499b553..93a3ec4a07 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -3528,9 +3528,12 @@  static int matroska_read_seek(AVFormatContext *s, int stream_index,
                   SEEK_SET);
         matroska->current_id = 0;
         while ((index = av_index_search_timestamp(st, timestamp, flags)) < 0 || index == st->nb_index_entries - 1) {
+            int64_t pos = avio_tell(matroska->ctx->pb);
             matroska_clear_queue(matroska);
-            if (matroska_parse_cluster(matroska) < 0)
-                break;
+            if (matroska_parse_cluster(matroska) < 0) {
+                if (matroska_resync(matroska, pos) < 0)
+                    break;
+            }
         }
     }