apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bojan Smojver" <bo...@rexursive.com>
Subject Re: Fwd: [PATCH] apr_pstrdup value returned by apr_env_get
Date Tue, 13 Sep 2011 07:43:36 GMT
------- Original message -------
> From: Ignaz Birnstingl <ignazb@gmail.com>

>Now if I use APR
> (pseudo code)
> char *foo = apr_env_get("foo");
> char *bar = apr_env_get("bar");
> if apr_env_get would pstrdup the string returned by getenv I could
> compare foo with bar, like this if (strcmp(foo, bar) == 0) ...

That is not necessarily true either. Suppose another thread called 
getenv("foo") just after getenv() and before strdup() in apr_env_get() of 
your thread. You would then get "foo" in your copy as well, because you'd 
be copying that same static buffer.

--
Bojan 

Mime
View raw message