os: ospoll_create(): protect from allocation failure

| ../os/ospoll.c: In function ‘ospoll_create’:
| ../os/ospoll.c:229:22: warning: dereference of possibly-NULL ‘ospoll’ [CWE-690] [-Wanalyzer-possible-null-dereference]
|   229 |     ospoll->epoll_fd = epoll_create1(EPOLL_CLOEXEC);
|       |     ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
Enrico Weigelt, metux IT consult 2025-05-06 15:06:12 +02:00
parent 1e2842f3e5
commit eb09c17a54

View File

@ -224,8 +224,9 @@ ospoll_create(void)
return ospoll;
#endif
#if EPOLL
struct ospoll *ospoll = calloc(1, sizeof (struct ospoll));
struct ospoll *ospoll = calloc(1, sizeof (struct ospoll));
if (ospoll == NULL)
return NULL;
ospoll->epoll_fd = epoll_create1(EPOLL_CLOEXEC);
if (ospoll->epoll_fd < 0) {
free (ospoll);