Re: [PATCH 2/3] http: try standard proxy env vars when http.proxy config option is not set

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Mar 01, 2012 at 10:57:03AM +0100, Nelson Benitez Leon wrote:

> > And I take back what I said about environment precedence, based on the
> > discussion. Also, I don't think there is a need to strdup the results of
> > getenv here, is there? So I think the code you want is just:
> > 
> >   if (!curl_http_proxy)
> >           curl_http_proxy = getenv("http_proxy");
> 
> but curl_http_proxy gets freed in http_cleanup as follows:
> 
> free((void *)curl_http_proxy);
> 
> Is it ok to free strings returned by getenv() ? I thought nope, so I
> used strdup which existent code was already using..

Ah, you're right. I was worried more about lifetime issues (i.e., would
the string still be valid) and didn't check to see whether we freed it
(and we should, because if it comes from config, then it will be
allocated). So yes, you should duplicate it.

-Peff
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]