httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From taka...@apache.org
Subject svn commit: r778448 - /httpd/httpd/trunk/support/logresolve.c
Date Mon, 25 May 2009 16:06:03 GMT
Author: takashi
Date: Mon May 25 16:06:03 2009
New Revision: 778448

URL: http://svn.apache.org/viewvc?rev=778448&view=rev
Log:
Fix a memory leak by freeing the memory every line. 

Modified:
    httpd/httpd/trunk/support/logresolve.c

Modified: httpd/httpd/trunk/support/logresolve.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/support/logresolve.c?rev=778448&r1=778447&r2=778448&view=diff
==============================================================================
--- httpd/httpd/trunk/support/logresolve.c (original)
+++ httpd/httpd/trunk/support/logresolve.c Mon May 25 16:06:03 2009
@@ -134,6 +134,7 @@
     apr_file_t * infile;
     apr_getopt_t * o;
     apr_pool_t * pool;
+    apr_pool_t *pline;
     apr_status_t status;
     const char * arg;
     char * stats = NULL;
@@ -202,6 +203,9 @@
 #endif
 
     cache = apr_hash_make(pool);
+    if(apr_pool_create(&pline, NULL) != APR_SUCCESS){
+        return 1;
+    }
 
     while (apr_file_gets(line, sizeof(line), infile) == APR_SUCCESS) {
         char *hostname;
@@ -241,7 +245,7 @@
         }
 
         /* Parse the IP address */
-        status = apr_sockaddr_info_get(&ip, line, APR_UNSPEC ,0, 0, pool);
+        status = apr_sockaddr_info_get(&ip, line, APR_UNSPEC, 0, 0, pline);
         if (status != APR_SUCCESS) {
             /* Not an IP address */
             withname++;
@@ -282,7 +286,7 @@
              * original IP address.
              */
             status = apr_sockaddr_info_get(&ipdouble, hostname, ip->family, 0,
-                                           0, pool);
+                                           0, pline);
             if (status == APR_SUCCESS ||
                 memcmp(ipdouble->ipaddr_ptr, ip->ipaddr_ptr, ip->ipaddr_len)) {
                 /* Double-lookup failed  */
@@ -304,6 +308,8 @@
         /* Store it in the cache */
         apr_hash_set(cache, line, APR_HASH_KEY_STRING,
                      apr_pstrdup(pool, hostname));
+
+        apr_pool_clear(pline);
     }
 
     /* Flush any remaining output */



Mime
View raw message