Fix: miscellaneous memory handling fixes
[lttng-tools.git] / src / common / compat / compat-epoll.c
index 25c9955045b3bb09435beea959d891c67f1c77a4..ecd09a0924a43f3aef6dbcd0fdb2055a45d44bb9 100644 (file)
@@ -51,6 +51,11 @@ static int resize_poll_event(struct lttng_poll_event *events,
                PERROR("realloc epoll add");
                goto error;
        }
+       if (new_size > events->alloc_size) {
+               /* Zero newly allocated memory */
+               memset(ptr + events->alloc_size, 0,
+                       (new_size - events->alloc_size) * sizeof(*ptr));
+       }
        events->events = ptr;
        events->alloc_size = new_size;
 
@@ -119,6 +124,11 @@ int compat_epoll_add(struct lttng_poll_event *events, int fd, uint32_t req_event
                goto error;
        }
 
+       /*
+        * Zero struct epoll_event to ensure all representations of its
+        * union are zeroed.
+        */
+       memset(&ev, 0, sizeof(ev));
        ev.events = req_events;
        ev.data.fd = fd;
 
This page took 0.024544 seconds and 4 git commands to generate.