You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by sf...@apache.org on 2012/12/25 21:43:15 UTC
svn commit: r1425771 - /httpd/httpd/trunk/server/config.c
Author: sf
Date: Tue Dec 25 20:43:15 2012
New Revision: 1425771
URL: http://svn.apache.org/viewvc?rev=1425771&view=rev
Log:
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
Modified:
httpd/httpd/trunk/server/config.c
Modified: httpd/httpd/trunk/server/config.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/config.c?rev=1425771&r1=1425770&r2=1425771&view=diff
==============================================================================
--- httpd/httpd/trunk/server/config.c (original)
+++ httpd/httpd/trunk/server/config.c Tue Dec 25 20:43:15 2012
@@ -603,7 +603,8 @@ AP_DECLARE(const char *) ap_add_module(m
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(m
/* 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*/