avcodec/cbs_av1: abort when written inferred values don't match

If this happens, it's a sign of parsing issues earlier in the process, or
misuse by the calling module.

Prevents writing invalid bitstreams.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: James Almer <jamrial@gmail.com>
This commit is contained in:
James Almer 2020-06-11 13:06:17 -03:00
parent ef13fafe22
commit 318a1a383d
1 changed files with 2 additions and 1 deletions

View File

@ -711,10 +711,11 @@ static size_t cbs_av1_get_payload_bytes_left(GetBitContext *gbc)
#define infer(name, value) do { \ #define infer(name, value) do { \
if (current->name != (value)) { \ if (current->name != (value)) { \
av_log(ctx->log_ctx, AV_LOG_WARNING, "Warning: " \ av_log(ctx->log_ctx, AV_LOG_ERROR, \
"%s does not match inferred value: " \ "%s does not match inferred value: " \
"%"PRId64", but should be %"PRId64".\n", \ "%"PRId64", but should be %"PRId64".\n", \
#name, (int64_t)current->name, (int64_t)(value)); \ #name, (int64_t)current->name, (int64_t)(value)); \
return AVERROR_INVALIDDATA; \
} \ } \
} while (0) } while (0)