[FFmpeg-devel,05/11] avformat/nutenc: Don't pass NULL to memcmp

Submitted by Andreas Rheinhardt on Sept. 19, 2019, 10:17 p.m.

Details

Message ID 20190919221706.16529-6-andreas.rheinhardt@gmail.com
State New
Headers show

Commit Message

Andreas Rheinhardt Sept. 19, 2019, 10:17 p.m.
Fixes lots of FATE tests, e.g. lavf-nut, as well as the nut part of
ticket #7980.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
---
This patch is made to match the previous behaviour; whether the previous
behaviour is correct at all if the header length is zero is unknown to
me.

 libavformat/nutenc.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Carl Eugen Hoyos Sept. 19, 2019, 11:22 p.m.
Am Fr., 20. Sept. 2019 um 00:30 Uhr schrieb Andreas Rheinhardt
<andreas.rheinhardt@gmail.com>:
>
> Fixes lots of FATE tests, e.g. lavf-nut, as well as the nut part of
> ticket #7980.
>
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
> ---
> This patch is made to match the previous behaviour; whether the previous
> behaviour is correct at all if the header length is zero is unknown to
> me.
>
>  libavformat/nutenc.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/libavformat/nutenc.c b/libavformat/nutenc.c
> index e9a3bb49db..dc714eb809 100644
> --- a/libavformat/nutenc.c
> +++ b/libavformat/nutenc.c
> @@ -791,8 +791,9 @@ static int get_needed_flags(NUTContext *nut, StreamContext *nus, FrameCode *fc,
>          flags |= FLAG_CHECKSUM;
>      if (pkt->size < nut->header_len[fc->header_idx] ||
>          (pkt->size > 4096 && fc->header_idx)        ||
> -        memcmp(pkt->data, nut->header[fc->header_idx],
> -               nut->header_len[fc->header_idx]))
> +        (nut->header_len[fc->header_idx] > 0 &&
> +         memcmp(pkt->data, nut->header[fc->header_idx],
> +                nut->header_len[fc->header_idx])))
>          flags |= FLAG_HEADER_IDX;

Is this different from the patch I sent?
(Why does it look different)
https://patchwork.ffmpeg.org/patch/13782/

Carl Eugen

Patch hide | download patch | download mbox

diff --git a/libavformat/nutenc.c b/libavformat/nutenc.c
index e9a3bb49db..dc714eb809 100644
--- a/libavformat/nutenc.c
+++ b/libavformat/nutenc.c
@@ -791,8 +791,9 @@  static int get_needed_flags(NUTContext *nut, StreamContext *nus, FrameCode *fc,
         flags |= FLAG_CHECKSUM;
     if (pkt->size < nut->header_len[fc->header_idx] ||
         (pkt->size > 4096 && fc->header_idx)        ||
-        memcmp(pkt->data, nut->header[fc->header_idx],
-               nut->header_len[fc->header_idx]))
+        (nut->header_len[fc->header_idx] > 0 &&
+         memcmp(pkt->data, nut->header[fc->header_idx],
+                nut->header_len[fc->header_idx])))
         flags |= FLAG_HEADER_IDX;
 
     return flags | (fc->flags & FLAG_CODED);