> From: Mikhail Gusarov <[email protected]>
> Date: Thu, 31 Mar 2011 14:18:13 +0200
> 
> Twas brillig at 13:13:23 31.03.2011 UTC+01 when [email protected]
> did gyre and gimble:
> 
>  >> +static const char *
>  >> +xau_getenv(const char *name)
>  >> +{
>  >> +    size_t  len        =3D 64;
>  >> +    char   *buffer =3D malloc (len);
>  >> +    int            rc =3D 0;
>  >> +
>  >> +    while (buffer
>  >> +        &&  (rc =3D getenv_r (name, buffer, len)) =3D=3D -1
>  >> +        &&  errno =3D=3D ERANGE) {
>  >> +        len *=3D 2;
>  >> +        free (buffer);
>  >> +        buffer =3D malloc (len);
>  >> +    }
>  >> +    return rc =3D=3D 0 ? buffer : NULL;
>  >> +}
>  MM> There's a (very unlikely) memory leak here.
>  MM> (getenv_r() =3D=3D -1 and errno !=3D ERANGE)
> 
> Actually quite likely:
> 
> [ENOENT] The variable name was not found in the environment.

It's probably best to drop the bit of the patch that tries to use
getenv_r(3) for now.  The standard getenv(3) on NetBSD provides
essentially the same amount of thread-safeness as the Solaris one
(safe with respect to another thread modifying the list of environment
variables, not safe with respect to another thread modifying the
environment variable you're looking at).
_______________________________________________
[email protected]: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

Reply via email to