diff mbox series

[FFmpeg-devel,2/4] avcodec/cbs: Check ctx for NULL in ff_cbs_flush()

Message ID 20221029191353.2973-2-michael@niedermayer.cc
State New
Headers show
Series [FFmpeg-devel,1/4] avformat/replaygain: avoid undefined / negative abs | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Michael Niedermayer Oct. 29, 2022, 7:13 p.m. UTC
Fixes: null pointer dereference
Fixes: 52155/clusterfuzz-testcase-minimized-ffmpeg_BSF_DTS2PTS_fuzzer-5760107527143424

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavcodec/cbs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Andreas Rheinhardt Oct. 29, 2022, 7:32 p.m. UTC | #1
Michael Niedermayer:
> Fixes: null pointer dereference
> Fixes: 52155/clusterfuzz-testcase-minimized-ffmpeg_BSF_DTS2PTS_fuzzer-5760107527143424
> 
> Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavcodec/cbs.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavcodec/cbs.c b/libavcodec/cbs.c
> index 504197e06d..9d59403f13 100644
> --- a/libavcodec/cbs.c
> +++ b/libavcodec/cbs.c
> @@ -120,7 +120,7 @@ av_cold int ff_cbs_init(CodedBitstreamContext **ctx_ptr,
>  
>  av_cold void ff_cbs_flush(CodedBitstreamContext *ctx)
>  {
> -    if (ctx->codec->flush)
> +    if (ctx && ctx->codec->flush)
>          ctx->codec->flush(ctx);
>  }
>  

The check should be in the dts2pts bsf instead.

- Andreas
diff mbox series

Patch

diff --git a/libavcodec/cbs.c b/libavcodec/cbs.c
index 504197e06d..9d59403f13 100644
--- a/libavcodec/cbs.c
+++ b/libavcodec/cbs.c
@@ -120,7 +120,7 @@  av_cold int ff_cbs_init(CodedBitstreamContext **ctx_ptr,
 
 av_cold void ff_cbs_flush(CodedBitstreamContext *ctx)
 {
-    if (ctx->codec->flush)
+    if (ctx && ctx->codec->flush)
         ctx->codec->flush(ctx);
 }