summaryrefslogtreecommitdiff
path: root/server/config.c
diff options
context:
space:
mode:
authorStefan Fritsch <sf@apache.org>2012-12-25 20:43:15 +0000
committerStefan Fritsch <sf@apache.org>2012-12-25 20:43:15 +0000
commit8ee1c0a5d794bed55fe0bc99fc4cbb26567f9ead (patch)
treeb55e846b9ea738d2d0cc367150310ae12172a492 /server/config.c
parent72ba8363435843a68481566d815ef6fe5630a397 (diff)
downloadhttpd-8ee1c0a5d794bed55fe0bc99fc4cbb26567f9ead.tar.gz
Replace strdup by ap_malloc to ensure a proper error message if out-of-memory.
While there, only allocate memory for the string part we actually use. PR: 54345 git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1425771 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'server/config.c')
-rw-r--r--server/config.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/server/config.c b/server/config.c
index 0483ce20cb..733d9c285f 100644
--- a/server/config.c
+++ b/server/config.c
@@ -603,7 +603,8 @@ AP_DECLARE(const char *) ap_add_module(module *m, apr_pool_t *p,
len -= slen;
}
- ap_module_short_names[m->module_index] = strdup(sym_name);
+ ap_module_short_names[m->module_index] = ap_malloc(len + 1);
+ memcpy(ap_module_short_names[m->module_index], sym_name, len);
ap_module_short_names[m->module_index][len] = '\0';
merger_func_cache[m->module_index] = m->merge_dir_config;
}
@@ -627,8 +628,9 @@ AP_DECLARE(const char *) ap_add_module(module *m, apr_pool_t *p,
/* We cannot fix the string in-place, because it's const */
if (m->name[strlen(m->name)-1] == ')') {
- char *tmp = strdup(m->name); /* FIXME: memory leak, albeit a small one */
- tmp[strlen(tmp)-1] = '\0';
+ char *tmp = ap_malloc(strlen(m->name)); /* FIXME: memory leak, albeit a small one */
+ memcpy(tmp, m->name, strlen(m->name)-1);
+ tmp[strlen(m->name)-1] = '\0';
m->name = tmp;
}
#endif /*_OSD_POSIX*/