diff mbox series

[FFmpeg-devel,25/39] lavc/hevcdec: move a slice segment sanity check to hls_slice_header()

Message ID 20240607130135.9088-25-anton@khirnov.net
State New
Headers show
Series [FFmpeg-devel,01/39] lavc/hevcdec: do not free SliceHeader arrays in pic_arrays_free() | expand

Commit Message

Anton Khirnov June 7, 2024, 1:01 p.m. UTC
Combine it with an existing similar check.
---
 libavcodec/hevc/hevcdec.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/hevc/hevcdec.c b/libavcodec/hevc/hevcdec.c
index df6d1565bc..9c1d879953 100644
--- a/libavcodec/hevc/hevcdec.c
+++ b/libavcodec/hevc/hevcdec.c
@@ -1002,7 +1002,8 @@  static int hls_slice_header(HEVCContext *s, GetBitContext *gb)
 
     sh->slice_ctb_addr_rs = sh->slice_segment_addr;
 
-    if (!s->sh.slice_ctb_addr_rs && s->sh.dependent_slice_segment_flag) {
+    if (sh->dependent_slice_segment_flag &&
+        (!sh->slice_ctb_addr_rs || !pps->ctb_addr_rs_to_ts[sh->slice_ctb_addr_rs])) {
         av_log(s->avctx, AV_LOG_ERROR, "Impossible slice segment.\n");
         return AVERROR_INVALIDDATA;
     }
@@ -2577,11 +2578,6 @@  static int hls_decode_entry(HEVCContext *s, GetBitContext *gb)
     int ctb_addr_ts = pps->ctb_addr_rs_to_ts[s->sh.slice_ctb_addr_rs];
     int ret;
 
-    if (!ctb_addr_ts && s->sh.dependent_slice_segment_flag) {
-        av_log(s->avctx, AV_LOG_ERROR, "Impossible initial tile.\n");
-        return AVERROR_INVALIDDATA;
-    }
-
     if (s->sh.dependent_slice_segment_flag) {
         int prev_rs = pps->ctb_addr_ts_to_rs[ctb_addr_ts - 1];
         if (s->tab_slice_address[prev_rs] != s->sh.slice_addr) {