]> git.sesse.net Git - ffmpeg/commitdiff
dump_extradata: Insert extradata even for small packets
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Sat, 14 Dec 2019 22:19:26 +0000 (23:19 +0100)
committerMichael Niedermayer <michael@niedermayer.cc>
Thu, 5 Mar 2020 23:58:31 +0000 (00:58 +0100)
3469cfab added a check for whether the extradata coincided with the
beginning of the packet's data in order not to add extradata to packets
that already have it. But the check used was buggy for packets whose
size is smaller than the extradata's size. This commit fixes this.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavcodec/dump_extradata_bsf.c

index b6415082343058ed0a026f2bd5668084708451f7..0b6d40479213fcf73b4dacd9744fd2734bf4be52 100644 (file)
@@ -51,8 +51,8 @@ static int dump_extradata(AVBSFContext *ctx, AVPacket *out)
     if (ctx->par_in->extradata &&
         (s->freq == DUMP_FREQ_ALL ||
          (s->freq == DUMP_FREQ_KEYFRAME && in->flags & AV_PKT_FLAG_KEY)) &&
-         in->size >= ctx->par_in->extradata_size &&
-         memcmp(in->data, ctx->par_in->extradata, ctx->par_in->extradata_size)) {
+         (in->size < ctx->par_in->extradata_size ||
+          memcmp(in->data, ctx->par_in->extradata, ctx->par_in->extradata_size))) {
         if (in->size >= INT_MAX - ctx->par_in->extradata_size) {
             ret = AVERROR(ERANGE);
             goto fail;