Hi,

On Tue, Aug 12, 2008 at 08:05:49PM +0200, zhengda wrote:

> +      char *name = NULL;

No need to initialize this -- the asprintf() will overwrite it anyways.

> +      if (__asprintf (&name, "SOCK_SERV_%d", domain) > 0)
> +        {
> +          np = getenv (name);
> +          __free (name);
> +        }

You need to check whether asprintf() returns an error code (-1), meaning
memory allocation failed, and handle it accordingly -- just like you
handled failure with the explicit malloc() in your original code.

If asprintf() doesn't fail, the getenv() should be done unconditionally.

> +          if (__asprintf (&name, "%s/%d", sock_servs, domain) > 0)
> +              np = name;

I think you can print to np directly here...

-antrik-


Reply via email to