diff --git a/libavcodec/shorten.c b/libavcodec/shorten.c
index ae0cdfe09d4be5d66cdcb988b4c425c30cea0b95..8aeacfeb3163399a413557a6159d2fdf858176a2 100644
--- a/libavcodec/shorten.c
+++ b/libavcodec/shorten.c
@@ -450,6 +450,10 @@ static int read_header(ShortenContext *s)
             return AVERROR_INVALIDDATA;
         }
         s->nmean = get_uint(s, 0);
+        if (s->nmean > 32768U) {
+            av_log(s->avctx, AV_LOG_ERROR, "nmean is: %d\n", s->nmean);
+            return AVERROR_INVALIDDATA;
+        }
 
         skip_bytes = get_uint(s, NSKIPSIZE);
         if ((unsigned)skip_bytes > get_bits_left(&s->gb)/8) {