diff --git a/libavcodec/shorten.c b/libavcodec/shorten.c
index b785284aa2d9a4856dee9e96884835aa09cfb0dd..18b77300a07d67f6f232ea010a66e286b2fae73f 100644
--- a/libavcodec/shorten.c
+++ b/libavcodec/shorten.c
@@ -445,6 +445,10 @@ static int read_header(ShortenContext *s)
         s->blocksize = blocksize;
 
         maxnlpc  = get_uint(s, LPCQSIZE);
+        if (maxnlpc > 1024U) {
+            av_log(s->avctx, AV_LOG_ERROR, "maxnlpc is: %d\n", maxnlpc);
+            return AVERROR_INVALIDDATA;
+        }
         s->nmean = get_uint(s, 0);
 
         skip_bytes = get_uint(s, NSKIPSIZE);