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:41:09 UTC
svn commit: r1593600 - in /apr/apr/branches/1.6.x: ./ memory/unix/apr_pools.c
Author: sf
Date: Fri May 9 19:41:09 2014
New Revision: 1593600
URL: http://svn.apache.org/r1593600
Log:
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.6.x/ (props changed)
apr/apr/branches/1.6.x/memory/unix/apr_pools.c
Propchange: apr/apr/branches/1.6.x/
------------------------------------------------------------------------------
Merged /apr/apr/trunk:r1438940
Modified: apr/apr/branches/1.6.x/memory/unix/apr_pools.c
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.6.x/memory/unix/apr_pools.c?rev=1593600&r1=1593599&r2=1593600&view=diff
==============================================================================
--- apr/apr/branches/1.6.x/memory/unix/apr_pools.c (original)
+++ apr/apr/branches/1.6.x/memory/unix/apr_pools.c Fri May 9 19:41:09 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;
}