X-Git-Url: https://git.liburcu.org/?a=blobdiff_plain;f=src%2Fcommon%2Fcompat%2Fcompat-poll.c;h=bc79eed0aaa5321c48fcd055858698bcdc5fa375;hb=ca0d78492eb30f538afab0406249bbc7c2492c80;hp=cff9f44b8e17c369a4b015866a825044bb43ef48;hpb=0af70327f35ffde444f22d18729782d8cc4cfbbb;p=lttng-tools.git diff --git a/src/common/compat/compat-poll.c b/src/common/compat/compat-poll.c index cff9f44b8..bc79eed0a 100644 --- a/src/common/compat/compat-poll.c +++ b/src/common/compat/compat-poll.c @@ -40,6 +40,11 @@ static int resize_poll_event(struct compat_poll_event_array *array, assert(array); + /* Refuse to resize the array more than the max size. */ + if (new_size > poll_max_size) { + goto error; + } + ptr = realloc(array->events, new_size * sizeof(*ptr)); if (ptr == NULL) { PERROR("realloc epoll add"); @@ -200,11 +205,6 @@ int compat_poll_del(struct lttng_poll_event *events, int fd) /* Ease our life a bit. */ current = &events->current; - /* Safety check on size */ - if (new_size > poll_max_size) { - new_size = poll_max_size; - } - /* Check if we need to shrink it down. */ if ((current->nb_fd << 1UL) <= current->alloc_size && current->nb_fd >= current->init_size) {