]> granicus.if.org Git - apache/commitdiff
* Reduce memory consumption when processing very long lines by at least
authorRuediger Pluem <rpluem@apache.org>
Mon, 19 Oct 2009 19:22:55 +0000 (19:22 +0000)
committerRuediger Pluem <rpluem@apache.org>
Mon, 19 Oct 2009 19:22:55 +0000 (19:22 +0000)
  doubleing the size of the new buffer each time.

PR: 48024
Submitted by: Basant Kumar Kukreja <basant.kukreja sun.com>
Reviewed by: rpluem

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

CHANGES
modules/filters/sed1.c

diff --git a/CHANGES b/CHANGES
index cee9e511029bcb8cb8ae6e3c668d7258f6a69c77..6973be23194aecefdee729079054261301120975 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -10,6 +10,9 @@ Changes with Apache 2.3.3
      mod_proxy_ftp: NULL pointer dereference on error paths.
      [Stefan Fritsch <sf fritsch.de>, Joe Orton]
 
+  *) mod_sed: Reduce memory consumption when processing very long lines.
+     PR 48024 [Basant Kumar Kukreja <basant.kukreja sun.com>]
+
   *) ab: Fix segfault in case the argument for -n is a very large number.
      PR 47178. [Philipp Hagemeister <oss phihag.de>]
 
index 24f16f050181a105e70b260b77ab44f97920eb3d..af26065365f7ca90a781424dcf5268913d2f8abe 100644 (file)
@@ -99,6 +99,12 @@ static void grow_buffer(apr_pool_t *pool, char **buffer,
     int spendsize = 0;
     if (*cursize >= newsize)
         return;
+    /* Avoid number of times realloc is called. It could cause huge memory
+     * requirement if line size is huge e.g 2 MB */
+    if (newsize < *cursize * 2) {
+        newsize = *cursize * 2;
+    }
+
     /* Align it to 4 KB boundary */
     newsize = (newsize  + ((1 << 12) - 1)) & ~((1 << 12) -1);
     newbuffer = apr_pcalloc(pool, newsize);