dgaudet     99/04/20 10:03:28

  Modified:    src      CHANGES
               src/main http_core.c
  Log:
  fix memory leak exacerbated by certain configurations
  
  PR:           4225
  
  Revision  Changes    Path
  1.1309    +3 -0      apache-1.3/src/CHANGES
  
  Index: CHANGES
  ===================================================================
  RCS file: /home/cvs/apache-1.3/src/CHANGES,v
  retrieving revision 1.1308
  retrieving revision 1.1309
  diff -u -r1.1308 -r1.1309
  --- CHANGES   1999/04/20 15:44:08     1.1308
  +++ CHANGES   1999/04/20 17:03:25     1.1309
  @@ -1,5 +1,8 @@
   Changes with Apache 1.3.7
   
  +  *) Fix a memory leak which is exacerbated by certain configurations.
  +     [Dean Gaudet] PR#4225
  +
     *) Prevent clobbering saved IFS values in APACI. [Jim Jagielski]
   
     *) Fix buffer overflows in ap_uuencode and ap_uudecode pointed out
  
  
  
  1.259     +7 -12     apache-1.3/src/main/http_core.c
  
  Index: http_core.c
  ===================================================================
  RCS file: /home/cvs/apache-1.3/src/main/http_core.c,v
  retrieving revision 1.258
  retrieving revision 1.259
  diff -u -r1.258 -r1.259
  --- http_core.c       1999/04/09 12:57:07     1.258
  +++ http_core.c       1999/04/20 17:03:27     1.259
  @@ -407,18 +407,16 @@
       int nelts;
       void **elts;
       int i;
  +    pool *tmp;
   
  -    /* XXX: we are about to waste some ram ... we will build a new array
  -     * and we need some scratch space to do it.  The old array and the
  -     * scratch space are never freed.
  -     */
       sconf = ap_get_module_config(s->module_config, &core_module);
       sec = sconf->sec;
       nelts = sec->nelts;
       elts = (void **)sec->elts;
   
  -    /* build our sorting space */
  -    sortbin = ap_palloc(p, sec->nelts * sizeof(*sortbin));
  +    /* we have to allocate tmp space to do a stable sort */
  +    tmp = ap_make_sub_pool(p);
  +    sortbin = ap_palloc(tmp, sec->nelts * sizeof(*sortbin));
       for (i = 0; i < nelts; ++i) {
        sortbin[i].orig_index = i;
        sortbin[i].elt = elts[i];
  @@ -426,15 +424,12 @@
   
       qsort(sortbin, nelts, sizeof(*sortbin), reorder_sorter);
   
  -    /* and now build a new array */
  -    /* XXX: uh I don't see why we can't reuse the old array, what
  -     * was I thinking? -djg */
  -    sec = ap_make_array(p, nelts, sizeof(void *));
  +    /* and now copy back to the original array */
       for (i = 0; i < nelts; ++i) {
  -     *(void **)ap_push_array(sec) = sortbin[i].elt;
  +      elts[i] = sortbin[i].elt;
       }
   
  -    sconf->sec = sec;
  +    ap_destroy_pool(tmp);
   }
   
   /*****************************************************************
  
  
  

Reply via email to