wrowe 2002/08/02 11:51:53
Modified: poll/unix poll.c
Log:
We safely ignore palloc failures [we can segv in the allocator].
We cannot ignore alloca/malloc failures.
Revision Changes Path
1.19 +8 -0 apr/poll/unix/poll.c
Index: poll.c
===================================================================
RCS file: /home/cvs/apr/poll/unix/poll.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- poll.c 2 Aug 2002 18:29:29 -0000 1.18
+++ poll.c 2 Aug 2002 18:51:53 -0000 1.19
@@ -114,9 +114,12 @@
{
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 @@
* 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++) {