]> git.ipfire.org Git - thirdparty/plymouth.git/commitdiff
event-loop: use static buffer instead of stack allocation buffer
authorJames Hunt <james.hunt@ubuntu.com>
Fri, 7 Oct 2011 15:32:46 +0000 (16:32 +0100)
committerRay Strode <rstrode@redhat.com>
Fri, 7 Oct 2011 18:26:09 +0000 (14:26 -0400)
alloca() isn't a good idea to use, in general, because it provides
undefined behavior when it fails.

This commit changes the epoll event buffer from being stack allocated
to static to avoid any potentially problems resulting from stack
space exhaustion.

https://bugs.freedesktop.org/show_bug.cgi?id=41562

src/libply/ply-event-loop.c

index a418c4efff6c179b41299027fc9af32b388df4e0..acfdc5db93cbcb07123bdf94fb1afcc3d8019a81 100644 (file)
@@ -1255,13 +1255,10 @@ void
 ply_event_loop_process_pending_events (ply_event_loop_t *loop)
 {
   int number_of_received_events, i;
-  struct epoll_event *events = NULL;
+  static struct epoll_event events[PLY_EVENT_LOOP_NUM_EVENT_HANDLERS];
 
   assert (loop != NULL);
 
-  events =
-        alloca (PLY_EVENT_LOOP_NUM_EVENT_HANDLERS * sizeof (struct epoll_event));
-
   memset (events, -1,
           PLY_EVENT_LOOP_NUM_EVENT_HANDLERS * sizeof (struct epoll_event));