diff --git a/libavcodec/aacdec.c b/libavcodec/aacdec.c
index b2fc740d4dbd249f975f4a1eb099919f27ace2ee..ca1a8764367cc76a0f8be966b00040da173235ef 100644
--- a/libavcodec/aacdec.c
+++ b/libavcodec/aacdec.c
@@ -2363,6 +2363,8 @@ static int latm_decode_audio_specific_config(struct LATMContext *latmctx,
                                "config not byte aligned.\n", 1);
         return AVERROR_INVALIDDATA;
     }
+    if (asclen <= 0)
+        return AVERROR_INVALIDDATA;
     bits_consumed = decode_audio_specific_config(NULL, avctx, &m4ac,
                                          gb->buffer + (config_start_bit / 8),
                                          asclen, sync_extension);