]> granicus.if.org Git - apache/commitdiff
Change a bunch of mallocs in mod_cgid to apr_palloc. These were never
authorRyan Bloom <rbb@apache.org>
Tue, 2 Jan 2001 17:57:42 +0000 (17:57 +0000)
committerRyan Bloom <rbb@apache.org>
Tue, 2 Jan 2001 17:57:42 +0000 (17:57 +0000)
getting freed, and using malloc.  This was safe, because we were in
the CGID process, but pools are just safer here.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@87569 13f79535-47bb-0310-9956-ffa450edef68

modules/generators/mod_cgid.c

index f183fc84208e5abff3e6dcaffe6e2f09172e2e3a..dd1c678800a20af501a16da8626b874baef66f77 100644 (file)
@@ -255,14 +255,17 @@ static void get_req(int fd, request_rec *r, char **filename, char **argv0, char
     read(fd, &i, sizeof(int)); 
      
     /* add 1, so that if i == 0, we still malloc something. */ 
-    dconf = (void **)malloc(sizeof(void *) * i + 1); 
+    dconf = (void **)apr_palloc(r->pool, sizeof(void *) * i + 1); 
+    temp_core = (core_dir_config *)apr_palloc(r->pool, sizeof(core_module)); 
+
+    dconf[i] = (void *)temp_core; 
+    r->per_dir_config = dconf; 
 
-    temp_core = (core_dir_config *)malloc(sizeof(core_module)); 
 #if 0
 #ifdef RLIMIT_CPU 
     read(fd, &j, sizeof(int)); 
     if (j) { 
-        temp_core->limit_cpu = (struct rlimit *)malloc (sizeof(struct rlimit)); 
+        temp_core->limit_cpu = (struct rlimit *)apr_palloc (sizeof(struct rlimit)); 
         read(fd, temp_core->limit_cpu, sizeof(struct rlimit)); 
     } 
     else { 
@@ -273,7 +276,7 @@ static void get_req(int fd, request_rec *r, char **filename, char **argv0, char
 #if defined (RLIMIT_DATA) || defined(RLIMIT_VMEM) || defined(RLIMIT_AS) 
     read(fd, &j, sizeof(int)); 
     if (j) { 
-        temp_core->limit_mem = (struct rlimit *)malloc (sizeof(struct rlimit)); 
+        temp_core->limit_mem = (struct rlimit *)apr_palloc(r->pool, sizeof(struct rlimit)); 
         read(fd, temp_core->limit_mem, sizeof(struct rlimit)); 
     } 
     else { 
@@ -284,7 +287,7 @@ static void get_req(int fd, request_rec *r, char **filename, char **argv0, char
 #ifdef RLIMIT_NPROC 
     read(fd, &j, sizeof(int)); 
     if (j) { 
-        temp_core->limit_nproc = (struct rlimit *)malloc (sizeof(struct rlimit)); 
+        temp_core->limit_nproc = (struct rlimit *)apr_palloc(r->pool, sizeof(struct rlimit)); 
         read(fd, temp_core->limit_nproc, sizeof(struct rlimit)); 
     } 
     else { 
@@ -292,9 +295,6 @@ static void get_req(int fd, request_rec *r, char **filename, char **argv0, char
     } 
 #endif 
 #endif
-    dconf[i] = (void *)temp_core; 
-    r->per_dir_config = dconf; 
-
     /* For right now, just make the notes table.  At some point we will need
      * to actually fill this out, but for now we just don't want suexec to
      * seg fault.