[FFmpeg-cvslog] avcodec/cbs_av1: don't call cbs_av1_read_trailing_bits() when no bits remain in the OBU

James Almer git at videolan.org
Mon Feb 11 02:02:46 EET 2019


ffmpeg | branch: release/4.1 | James Almer <jamrial at gmail.com> | Sun Feb 10 17:41:38 2019 -0300| [33c8009773500fe969af9044a81ca6b18a17a83d] | committer: James Almer

avcodec/cbs_av1: don't call cbs_av1_read_trailing_bits() when no bits remain in the OBU

Reviewed-by: jkqxz
Signed-off-by: James Almer <jamrial at gmail.com>
(cherry picked from commit 3e8b8b6b509c8c37defd3a8c32883fa54bc00de8)

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

 libavcodec/cbs_av1.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/libavcodec/cbs_av1.c b/libavcodec/cbs_av1.c
index 535139e703..4513287ef9 100644
--- a/libavcodec/cbs_av1.c
+++ b/libavcodec/cbs_av1.c
@@ -1071,8 +1071,12 @@ static int cbs_av1_read_unit(CodedBitstreamContext *ctx,
     if (obu->obu_size > 0 &&
         obu->header.obu_type != AV1_OBU_TILE_GROUP &&
         obu->header.obu_type != AV1_OBU_FRAME) {
-        err = cbs_av1_read_trailing_bits(ctx, &gbc,
-                                         obu->obu_size * 8 + start_pos - end_pos);
+        int nb_bits = obu->obu_size * 8 + start_pos - end_pos;
+
+        if (nb_bits <= 0)
+            return AVERROR_INVALIDDATA;
+
+        err = cbs_av1_read_trailing_bits(ctx, &gbc, nb_bits);
         if (err < 0)
             return err;
     }



More information about the ffmpeg-cvslog mailing list