Re: [PATCH] revolve possible null pointer dereference issue found by cppcheck

2018-04-09 Thread Илья Шипицин
thank you.
sorry for false positive

2018-04-09 12:43 GMT+05:00 Michal Srb :

> 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);
>
>
>
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

Re: [PATCH] revolve possible null pointer dereference issue found by cppcheck

2018-04-09 Thread Michal Srb
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);


___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

[PATCH] revolve possible null pointer dereference issue found by cppcheck

2018-04-09 Thread Ilya Shipitsin
[dix/inpututils.c:909] -> [dix/inpututils.c:905]: (warning) Either the condition
'if(list)' is redundant or there is possible null pointer dereference: list.

Signed-off-by: Ilya Shipitsin 
---
 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);
 
-- 
2.14.3

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel