[PATCH] revolve possible null pointer dereference issue found by cppcheck
Илья Шипицин
chipitsine at gmail.com
Mon Apr 9 08:06:09 UTC 2018
thank you.
sorry for false positive
2018-04-09 12:43 GMT+05:00 Michal Srb <msrb at suse.com>:
> On pondělí 9. dubna 2018 9:31:54 CEST Ilya Shipitsin wrote:
> > [dix/inpututils.c:909] -> [dix/inpututils.c:905]: (warning) Either the
> > condition 'if(list)' is redundant or there is possible null pointer
> > dereference: list.
>
> I think this is a false positive by cppcheck. It looks like it
> misinterprets
> the `list.next` in the macro as dereferencing the `list` variable.
>
> The `nt_list_init(opt, list.next)` macro expands to:
>
> (opt)->list.next = NULL
>
> So wrapping it in the `if (list)` condition is not correct.
>
> Michal Srb
>
> > ---
> > dix/inpututils.c | 4 +++-
> > 1 file changed, 3 insertions(+), 1 deletion(-)
> >
> > diff --git a/dix/inpututils.c b/dix/inpututils.c
> > index 6bff9efab..f4c386a24 100644
> > --- a/dix/inpututils.c
> > +++ b/dix/inpututils.c
> > @@ -902,7 +902,9 @@ input_option_new(InputOption *list, const char *key,
> > const char *value) if (!opt)
> > return NULL;
> >
> > - nt_list_init(opt, list.next);
> > + if (list)
> > + nt_list_init(opt, list.next);
> > +
> > input_option_set_key(opt, key);
> > input_option_set_value(opt, value);
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.x.org/archives/xorg-devel/attachments/20180409/31c6f0a5/attachment.html>
More information about the xorg-devel
mailing list