From 5bacf014cfb26eeffe114716fce17cdee5667cab Mon Sep 17 00:00:00 2001 From: wrowe Date: Fri, 2 Aug 2002 18:51:53 +0000 Subject: We safely ignore palloc failures [we can segv in the allocator]. We cannot ignore alloca/malloc failures. git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@63771 13f79535-47bb-0310-9956-ffa450edef68 --- poll/unix/poll.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/poll/unix/poll.c b/poll/unix/poll.c index b63645e1d..a6f25e353 100644 --- a/poll/unix/poll.c +++ b/poll/unix/poll.c @@ -114,9 +114,12 @@ APR_DECLARE(apr_status_t) apr_poll(apr_pollfd_t *aprset, apr_int32_t num, { int i; #ifdef HAVE_VLA + /* XXX: I trust that this is a segv when insufficient stack exists? */ struct pollfd pollset[num]; #elif defined(HAVE_ALLOCA) struct pollfd *pollset = alloca(sizeof(pollfd) * num); + if (!pollset) + return APR_ENOMEM; #else struct pollfd tmp_pollset[SMALL_POLLSET_LIMIT]; struct pollfd *pollset; @@ -129,6 +132,11 @@ APR_DECLARE(apr_status_t) apr_poll(apr_pollfd_t *aprset, apr_int32_t num, * mapping. */ pollset = malloc(sizeof(struct pollfd) * num); + /* The other option is adding an apr_pool_abort() fn to invoke + * the pool's out of memory handler + */ + if (!pollset) + return APR_ENOMEM; } #endif for (i = 0; i < num; i++) { -- cgit v1.2.1