summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGreg Stein <gstein@apache.org>2000-06-26 23:35:28 +0000
committerGreg Stein <gstein@apache.org>2000-06-26 23:35:28 +0000
commit5e3d12062311eedad6fd43a5b95537e378e0cd1c (patch)
treed6762d8cf99ec0d858897c708a6e45d7549fb2a5 /lib
parentd75e7b73ee8cafc7cbd0457f886faba467cb15e2 (diff)
downloadapr-5e3d12062311eedad6fd43a5b95537e378e0cd1c.tar.gz
A string constant was straddling a newline. Badness.
(separate fix by Greg: #if an Apache function call out of existence, and optimize the function by computing length once and memcpy'ing) Submitted by: "Victor J. Orlikowski" <vjo@raleigh.ibm.com> Reviewed by: Greg Stein git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@60262 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'lib')
-rw-r--r--lib/apr_cpystrn.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/lib/apr_cpystrn.c b/lib/apr_cpystrn.c
index 17f270145..37fd2bad5 100644
--- a/lib/apr_cpystrn.c
+++ b/lib/apr_cpystrn.c
@@ -248,12 +248,17 @@ APR_EXPORT(char *) ap_collapse_spaces(char *dest, const char *src)
char *strdup(const char *str)
{
char *sdup;
- if (!(sdup = (char *) malloc(strlen(str) + 1))) {
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, "Ouch!
- Out of memory in our strdup()!");
+ size_t len = strlen(str) + 1;
+
+ if (!(sdup = (char *) malloc(len))) {
+ /* ### whoops! we can't call Apache logging routines here... */
+#if 0
+ ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
+ "Ouch! Out of memory in our strdup()!");
+#endif
return NULL;
}
- sdup = strcpy(sdup, str);
+ memcpy(sdup, str, len);
return sdup;
}