You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by sf...@apache.org on 2014/05/09 21:55:08 UTC

svn commit: r1593610 - in /apr/apr/branches/1.5.x: ./ memory/unix/apr_pools.c

Author: sf
Date: Fri May  9 19:55:08 2014
New Revision: 1593610

URL: http://svn.apache.org/r1593610
Log:
Backport r1593600 from 1.6:
Backport r1438940 from trunk:

    Don't leak memnodes in apr_pvsprintf() if out of memory and no pool abort
    function is set


Modified:
    apr/apr/branches/1.5.x/   (props changed)
    apr/apr/branches/1.5.x/memory/unix/apr_pools.c

Propchange: apr/apr/branches/1.5.x/
------------------------------------------------------------------------------
  Merged /apr/apr/trunk:r1438940
  Merged /apr/apr/branches/1.6.x:r1593600

Modified: apr/apr/branches/1.5.x/memory/unix/apr_pools.c
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.5.x/memory/unix/apr_pools.c?rev=1593610&r1=1593609&r2=1593610&view=diff
==============================================================================
--- apr/apr/branches/1.5.x/memory/unix/apr_pools.c (original)
+++ apr/apr/branches/1.5.x/memory/unix/apr_pools.c Fri May  9 19:55:08 2014
@@ -1135,21 +1135,12 @@ APR_DECLARE(char *) apr_pvsprintf(apr_po
      * room to hold the NUL terminator.
      */
     if (ps.node->first_avail == ps.node->endp) {
-        if (psprintf_flush(&ps.vbuff) == -1) {
-            if (pool->abort_fn) {
-                pool->abort_fn(APR_ENOMEM);
-            }
-
-            return NULL;
-        }
+        if (psprintf_flush(&ps.vbuff) == -1)
+           goto error;
     }
 
-    if (apr_vformatter(psprintf_flush, &ps.vbuff, fmt, ap) == -1) {
-        if (pool->abort_fn)
-            pool->abort_fn(APR_ENOMEM);
-
-        return NULL;
-    }
+    if (apr_vformatter(psprintf_flush, &ps.vbuff, fmt, ap) == -1)
+        goto error;
 
     strp = ps.vbuff.curpos;
     *strp++ = '\0';
@@ -1195,6 +1186,15 @@ APR_DECLARE(char *) apr_pvsprintf(apr_po
     list_insert(active, node);
 
     return strp;
+
+error:
+    if (pool->abort_fn)
+        pool->abort_fn(APR_ENOMEM);
+    if (ps.got_a_new_node) {
+        ps.node->next = ps.free;
+        allocator_free(pool->allocator, ps.node);
+    }
+    return NULL;
 }