[FFmpeg-devel] [PATCH 2/6] lavc/avpacket: check NULL before using the pointer
Michael Niedermayer
michael at niedermayer.cc
Sat May 11 02:25:02 EEST 2019
On Fri, May 10, 2019 at 10:00:54PM +0200, Carl Eugen Hoyos wrote:
> Am Fr., 10. Mai 2019 um 18:13 Uhr schrieb Jun Zhao <mypopydev at gmail.com>:
> >
> > From: Jun Zhao <barryjzhao at tencent.com>
> >
> > Need to check NULL before using the pointer
> >
> > Signed-off-by: Jun Zhao <barryjzhao at tencent.com>
> > ---
> > libavcodec/avpacket.c | 3 ++-
> > 1 files changed, 2 insertions(+), 1 deletions(-)
> >
> > diff --git a/libavcodec/avpacket.c b/libavcodec/avpacket.c
> > index 8f0603d..2b20067 100644
> > --- a/libavcodec/avpacket.c
> > +++ b/libavcodec/avpacket.c
> > @@ -522,11 +522,12 @@ fail:
> >
> > int av_packet_unpack_dictionary(const uint8_t *data, int size, AVDictionary **dict)
> > {
> > - const uint8_t *end = data + size;
> > + const uint8_t *end;
> > int ret = 0;
> >
> > if (!dict || !data || !size)
> > return ret;
> > + end = data + size;
>
> Could somebody explain to me why this is necessary?
if data is NULL adding a non zero value to it would be undefined behavior
i think
thx
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
There will always be a question for which you do not know the correct answer.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20190511/f55d8060/attachment.sig>
More information about the ffmpeg-devel
mailing list