apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ignaz Birnstingl <ign...@gmail.com>
Subject Fwd: [PATCH] apr_pstrdup value returned by apr_env_get
Date Mon, 12 Sep 2011 07:38:10 GMT
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
-) 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.


---------- Forwarded message ----------
From: Ignaz Birnstingl <ignazb@gmail.com>
Date: 2011/8/19
Subject: [PATCH] apr_pstrdup value returned by apr_env_get
To: dev@apr.apache.org

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;



View raw message