httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Cliff Woolley <cliffwool...@yahoo.com>
Subject [PATCH] memory leak in file bucket destruction
Date Thu, 01 Feb 2001 22:14:39 GMT

> --- rbb@covalent.net wrote:
> > You are correct, it should call destroy_shared.  This was broken when I
> > added native copy and split to files, and I didn't think of the free
> > function.

This little patch simultaneously removes file_split() (because all it did was duplicate
the effort of apr_bucket_split_shared()) and add file_destroy(), which is needed now that
the file buckets are refcounted.  This should fix a memory leak, but as I said in my last
post, I can't see any way that it would help with the heap corruption problem.  That
one's still up in the air.

--Cliff


Index: apr_buckets_file.c
===================================================================
RCS file: /home/cvspublic/apr-util/buckets/apr_buckets_file.c,v
retrieving revision 1.25
diff -u -r1.25 apr_buckets_file.c
--- apr_buckets_file.c	2001/01/24 08:26:19	1.25
+++ apr_buckets_file.c	2001/02/01 22:08:34
@@ -164,21 +164,15 @@
     return APR_SUCCESS;
 }
 
-static apr_status_t file_split(apr_bucket *e, apr_off_t offset)
+static void file_destroy(void *data)
 {
-    apr_bucket *b;
-    apr_bucket_shared *s;
-    apr_bucket_shared *temp = e->data;
     apr_bucket_file *f;
 
-    apr_bucket_split_shared(e, offset);
-    b = APR_BUCKET_NEXT(e);
-
-    s = b->data;
-    f = s->data;
-    s->start = offset + temp->start;
-
-    return APR_SUCCESS;
+    f = apr_bucket_destroy_shared(data);
+    if (f == NULL) {
+        return;
+    }
+    free(f);
 }
 
 APU_DECLARE(apr_bucket *) apr_bucket_make_file(apr_bucket *b, apr_file_t *fd,
@@ -211,9 +205,9 @@
 
 APU_DECLARE_DATA const apr_bucket_type_t apr_bucket_type_file = {
     "FILE", 5,
-    free,
+    file_destroy,
     file_read,
     apr_bucket_setaside_notimpl,
-    file_split,
+    apr_bucket_split_shared,
     apr_bucket_copy_shared
 };

__________________________________________________
Get personalized email addresses from Yahoo! Mail - only $35 
a year!  http://personal.mail.yahoo.com/

Mime
View raw message