diff --git a/libavcodec/assdec.c b/libavcodec/assdec.c
index 087a0c839b35e97af9f84bce1e23ecfda40d14d7..c5f9cab6e008dffbeaeb3f8e02e758b85195252e 100644
--- a/libavcodec/assdec.c
+++ b/libavcodec/assdec.c
@@ -26,7 +26,7 @@
 static av_cold int ass_decode_init(AVCodecContext *avctx)
 {
     avctx->subtitle_header = av_malloc(avctx->extradata_size);
-    if (!avctx->extradata)
+    if (!avctx->subtitle_header)
         return AVERROR(ENOMEM);
     memcpy(avctx->subtitle_header, avctx->extradata, avctx->extradata_size);
     avctx->subtitle_header_size = avctx->extradata_size;