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 2011/10/16 16:20:16 UTC

svn commit: r1184831 - /httpd/mod_mbox/trunk/module-2.0/mod_mbox_mime.c

Author: sf
Date: Sun Oct 16 14:20:16 2011
New Revision: 1184831

URL: http://svn.apache.org/viewvc?rev=1184831&view=rev
Log:
Fix memory leak

Modified:
    httpd/mod_mbox/trunk/module-2.0/mod_mbox_mime.c

Modified: httpd/mod_mbox/trunk/module-2.0/mod_mbox_mime.c
URL: http://svn.apache.org/viewvc/httpd/mod_mbox/trunk/module-2.0/mod_mbox_mime.c?rev=1184831&r1=1184830&r2=1184831&view=diff
==============================================================================
--- httpd/mod_mbox/trunk/module-2.0/mod_mbox_mime.c (original)
+++ httpd/mod_mbox/trunk/module-2.0/mod_mbox_mime.c Sun Oct 16 14:20:16 2011
@@ -19,6 +19,13 @@
 
 #include "mod_mbox.h"
 
+static apr_status_t cleanup_mime_msg(void *data)
+{
+    mbox_mime_message_t *mail = data;
+    free(mail->sub);
+    return APR_SUCCESS;
+}
+
 /* Decode a multipart (or not) email. In order to support multiple
  * levels of MIME parts, this function is recursive.
  */
@@ -55,6 +62,8 @@ mbox_mime_message_t *mbox_mime_decode_mu
     }
 
     mail = apr_pcalloc(p, sizeof(mbox_mime_message_t));
+    /* make sure the memory allocated by realloc() below is cleaned up */
+    apr_pool_cleanup_register(p, mail, cleanup_mime_msg, apr_pool_cleanup_null);
 
     /* If no Content-Type is given, we have to look for it. */
     if (!ct) {