diff --git a/libavcodec/elsdec.c b/libavcodec/elsdec.c
index 5e89045864b15ac0c51f77b235c411cd7f41cf96..10a1a9d5e89550653bb9ed90c952a38042271277 100644
--- a/libavcodec/elsdec.c
+++ b/libavcodec/elsdec.c
@@ -362,7 +362,7 @@ unsigned ff_els_decode_unsigned(ElsDecCtx *ctx, ElsUnsignedRung *ur)
 
     /* handle the error/overflow case */
     if (ctx->err || n >= ELS_EXPGOLOMB_LEN) {
-        ctx->err = AVERROR(EOVERFLOW);
+        ctx->err = AVERROR_INVALIDDATA;
         return 0;
     }