Do variable length arrays the C99 way

Variable length arrays are supported by C99, but having it denoted as "1" confused the compiler and is not defined.

Note that because we don't get the inferred NULL terminator, we have to increase the malloc size by one.
This commit is contained in:
Rose
2023-05-18 14:49:45 -04:00
parent 64b666471a
commit 7fd680c983
6 changed files with 10 additions and 10 deletions

View File

@@ -291,7 +291,7 @@ sudo_ev_set_v1(struct sudo_event *ev, int fd, short events,
/* For SUDO_EV_SIGINFO we use a container to store closure + siginfo_t */
if (ISSET(events, SUDO_EV_SIGINFO)) {
struct sudo_ev_siginfo_container *container =
malloc(sizeof(*container) + sizeof(siginfo_t) - 1);
malloc(sizeof(*container) + sizeof(siginfo_t));
if (container == NULL) {
sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO,
"%s: unable to allocate siginfo container", __func__);