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 2013/01/26 19:44:29 UTC
svn commit: r1438940 - /apr/apr/trunk/memory/unix/apr_pools.c
Author: sf
Date: Sat Jan 26 18:44:29 2013
New Revision: 1438940
URL: http://svn.apache.org/viewvc?rev=1438940&view=rev
Log:
Don't leak memnodes in apr_pvsprintf() if out of memory and no pool abort
function is set.
Modified:
apr/apr/trunk/memory/unix/apr_pools.c
Modified: apr/apr/trunk/memory/unix/apr_pools.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/memory/unix/apr_pools.c?rev=1438940&r1=1438939&r2=1438940&view=diff
==============================================================================
--- apr/apr/trunk/memory/unix/apr_pools.c (original)
+++ apr/apr/trunk/memory/unix/apr_pools.c Sat Jan 26 18:44:29 2013
@@ -1147,21 +1147,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';
@@ -1207,6 +1198,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;
}