diff mbox

[FFmpeg-devel] avformat/mov: Propagate errors in mov_switch_root.

Message ID 20171117002822.101228-1-modmaker@google.com
State Superseded
Headers show

Commit Message

Jacob Trimble Nov. 17, 2017, 12:28 a.m. UTC
Signed-off-by: Jacob Trimble <modmaker@google.com>
---
 libavformat/mov.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

Derek Buitenhuis Nov. 17, 2017, 12:38 a.m. UTC | #1
On 11/17/2017 12:28 AM, Jacob Trimble wrote:
> Signed-off-by: Jacob Trimble <modmaker@google.com>
> ---
>  libavformat/mov.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)

Looks OK.

- Derek
Moritz Barsnick Nov. 18, 2017, 1:55 a.m. UTC | #2
On Thu, Nov 16, 2017 at 16:28:22 -0800, Jacob Trimble wrote:
> -    if (mov_read_default(mov, s->pb, (MOVAtom){ AV_RL32("root"), INT64_MAX }) < 0 ||
> -        avio_feof(s->pb))
> +    if ((ret = mov_read_default(mov, s->pb, (MOVAtom){ AV_RL32("root"), INT64_MAX })) < 0)
> +        return ret;
> +    if (avio_feof(s->pb))
>          return AVERROR_EOF;

The recommendation is to use:

    ret = mov_read_default(mov, s->pb, (MOVAtom){ AV_RL32("root"), INT64_MAX });
    if (ret < 0)
        return ret;

in new code.

Moritz
diff mbox

Patch

diff --git a/libavformat/mov.c b/libavformat/mov.c
index d49d820d2b..c5f07595df 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -6747,6 +6747,7 @@  static int should_retry(AVIOContext *pb, int error_code) {
 
 static int mov_switch_root(AVFormatContext *s, int64_t target, int index)
 {
+    int ret;
     MOVContext *mov = s->priv_data;
 
     if (index >= 0 && index < mov->frag_index.nb_items)
@@ -6769,8 +6770,9 @@  static int mov_switch_root(AVFormatContext *s, int64_t target, int index)
 
     mov->found_mdat = 0;
 
-    if (mov_read_default(mov, s->pb, (MOVAtom){ AV_RL32("root"), INT64_MAX }) < 0 ||
-        avio_feof(s->pb))
+    if ((ret = mov_read_default(mov, s->pb, (MOVAtom){ AV_RL32("root"), INT64_MAX })) < 0)
+        return ret;
+    if (avio_feof(s->pb))
         return AVERROR_EOF;
     av_log(s, AV_LOG_TRACE, "read fragments, offset 0x%"PRIx64"\n", avio_tell(s->pb));