[Piglit] [PATCH] cl-tests: don't pass NULL ptr to initial strtok call

Jan Vesely jan.vesely at rutgers.edu
Mon Jun 15 06:38:31 PDT 2015


On Mon, Jun 15, 2015 at 3:22 AM, Lucas Stach <l.stach at pengutronix.de> wrote:

> Given that this patch is really trivial, I'm going to push this by
> tomorrow if nobody objects.
>
> Regards,
> Lucas
>
> Am Montag, den 08.06.2015, 12:45 +0200 schrieb Lucas Stach:
> > If the test don't require specific extensions a NULL ptr is
> > passed to the initial call of strtok(). Apparently this works on
> > x86, but it is undocumented behavior and crashes on other arches.
> >
> > Fix the segfault by bailing out early in this case.
>

didn't find anything explicit about the arguments on the first call in the
manpage, so I guess it's legal to crash on NULL.

Reviewed-by: Jan Vesely <jan.vesely at rutgers.edu>


> >
> > Signed-off-by: Lucas Stach <l.stach at pengutronix.de>
> > ---
> >  tests/util/piglit-framework-cl.c | 6 ++++++
> >  1 file changed, 6 insertions(+)
> >
> > diff --git a/tests/util/piglit-framework-cl.c
> b/tests/util/piglit-framework-cl.c
> > index 9a7efef1d93b..9dc73c7e3508 100644
> > --- a/tests/util/piglit-framework-cl.c
> > +++ b/tests/util/piglit-framework-cl.c
> > @@ -86,6 +86,9 @@ bool check_platform_extensions(cl_platform_id
> platform_id, char* extensions)
> >  {
> >       char* pch;
> >
> > +     if (!extensions)
> > +             return true;
> > +
> >       pch = strtok(extensions, " ");
> >       while(pch != NULL) {
> >               if(   strlen(pch) > 0
> > @@ -108,6 +111,9 @@ bool check_device_extensions(cl_device_id device_id,
> char* extensions)
> >  {
> >       char* pch;
> >
> > +     if (!extensions)
> > +             return true;
> > +
> >       pch = strtok(extensions, " ");
> >       while(pch != NULL) {
> >               if(   strlen(pch) > 0
>
> --
> Pengutronix e.K.             | Lucas Stach                 |
> Industrial Linux Solutions   | http://www.pengutronix.de/  |
>
> _______________________________________________
> Piglit mailing list
> Piglit at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/piglit
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/piglit/attachments/20150615/7c741133/attachment.html>


More information about the Piglit mailing list