diff mbox series

[FFmpeg-devel,2/2] avcodec/av1_metadata_bsf: Check for the existence of units

Message ID HE1PR0301MB2154A1B04B7B5235F6CDAD1F8F7A9@HE1PR0301MB2154.eurprd03.prod.outlook.com
State Accepted
Commit 8081a0b10f5325b60e885d8823593485019b8a18
Headers show
Series [FFmpeg-devel,1/2] avcodec/h264_metadata_bsf: Don't add AUD to extradata
Related show

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

Andreas Rheinhardt April 2, 2021, 3:39 p.m. UTC
Fixes a crash with ISOBMFF extradata containing no OBUs.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/av1_metadata_bsf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

James Almer April 2, 2021, 3:51 p.m. UTC | #1
On 4/2/2021 12:39 PM, Andreas Rheinhardt wrote:
> Fixes a crash with ISOBMFF extradata containing no OBUs.
> 
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> ---
>   libavcodec/av1_metadata_bsf.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavcodec/av1_metadata_bsf.c b/libavcodec/av1_metadata_bsf.c
> index 8cafe461d1..328db5c0da 100644
> --- a/libavcodec/av1_metadata_bsf.c
> +++ b/libavcodec/av1_metadata_bsf.c
> @@ -120,7 +120,7 @@ static int av1_metadata_update_fragment(AVBSFContext *bsf, AVPacket *pkt,
>       }
>   
>       // If a Temporal Delimiter is present, it must be the first OBU.
> -    if (frag->units[0].type == AV1_OBU_TEMPORAL_DELIMITER) {
> +    if (frag->nb_units && frag->units[0].type == AV1_OBU_TEMPORAL_DELIMITER) {
>           if (ctx->td == BSF_ELEMENT_REMOVE)
>               ff_cbs_delete_unit(frag, 0);
>       } else if (pkt && ctx->td == BSF_ELEMENT_INSERT) {

Should be ok. And backport it, too.
diff mbox series

Patch

diff --git a/libavcodec/av1_metadata_bsf.c b/libavcodec/av1_metadata_bsf.c
index 8cafe461d1..328db5c0da 100644
--- a/libavcodec/av1_metadata_bsf.c
+++ b/libavcodec/av1_metadata_bsf.c
@@ -120,7 +120,7 @@  static int av1_metadata_update_fragment(AVBSFContext *bsf, AVPacket *pkt,
     }
 
     // If a Temporal Delimiter is present, it must be the first OBU.
-    if (frag->units[0].type == AV1_OBU_TEMPORAL_DELIMITER) {
+    if (frag->nb_units && frag->units[0].type == AV1_OBU_TEMPORAL_DELIMITER) {
         if (ctx->td == BSF_ELEMENT_REMOVE)
             ff_cbs_delete_unit(frag, 0);
     } else if (pkt && ctx->td == BSF_ELEMENT_INSERT) {