diff --git a/libavcodec/yop.c b/libavcodec/yop.c
index 05abb245530a0a291e7bb701a5fb67aa4890286e..ac17297915307a391fdade9e33c61d43456cc7ad 100644
--- a/libavcodec/yop.c
+++ b/libavcodec/yop.c
@@ -89,6 +89,11 @@ static av_cold int yop_decode_init(AVCodecContext *avctx)
         return -1;
     }
 
+    if (!avctx->extradata) {
+        av_log(avctx, AV_LOG_ERROR, "extradata missing\n");
+        return AVERROR_INVALIDDATA;
+    }
+
     avctx->pix_fmt = PIX_FMT_PAL8;
 
     avcodec_get_frame_defaults(&s->frame);