avcodec/utils: Check close before calling it
authorMichael Niedermayer <michael@niedermayer.cc>
Sat, 20 Jul 2019 22:08:55 +0000 (00:08 +0200)
committerMichael Niedermayer <michael@niedermayer.cc>
Sun, 21 Jul 2019 10:39:42 +0000 (12:39 +0200)
Fixes: NULL pointer dereference
Fixes: 15733/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_IDF_fuzzer-5658616977162240

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavcodec/utils.c

index 9ff9628..66c68d1 100644 (file)
@@ -1024,7 +1024,7 @@ end:
 
     return ret;
 free_and_end:
-    if (avctx->codec &&
+    if (avctx->codec && avctx->codec->close &&
         (codec_init_ok ||
          (avctx->codec->caps_internal & FF_CODEC_CAP_INIT_CLEANUP)))
         avctx->codec->close(avctx);