I guess the patch didn't make it to trunk so I'll restate why I think this should make it to future versions of APR: -) The documentation says about argument pool: "where to allocate value and any temporary storage from". If *value is not allocated from pool then manipulating the data pointed to it can have any kinds of side-effects. -) The single UNIX specification states that getenv() "need not be reentrant" and in fact it is not on some platforms, like the z/OS USS. Thus apr_env_get is not reentrant on some platforms. Even with my patch the documentation should probably state that the function is not thread-safe and requires external serialization.
Thanks, Ignaz ---------- Forwarded message ---------- From: Ignaz Birnstingl <[email protected]> Date: 2011/8/19 Subject: [PATCH] apr_pstrdup value returned by apr_env_get To: [email protected] apr_env_get should pstrdup the value it returns - as it does according to its documentation. Index: misc/unix/env.c =================================================================== --- misc/unix/env.c (revision 1159605) +++ misc/unix/env.c (working copy) @@ -37,7 +37,7 @@ char *val = getenv(envvar); if (!val) return APR_ENOENT; - *value = val; + *value = apr_pstrdup(pool, val); return APR_SUCCESS; #else -- Ignaz
