diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c
index 6cd646a9e7907f7e7ab4ee982cc969b0548843eb..c0a8b1f1e1822f0c87524cb2e489d6b7be401c88 100644
--- a/libavcodec/jpeg2000dec.c
+++ b/libavcodec/jpeg2000dec.c
@@ -171,6 +171,8 @@ static int pix_fmt_match(enum AVPixelFormat pix_fmt, int components,
     int match = 1;
     const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
 
+    av_assert2(desc);
+
     if (desc->nb_components != components) {
         return 0;
     }