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:
parent
1e2842f3e5
commit
eb09c17a54
|
@ -225,7 +225,8 @@ ospoll_create(void)
|
||||||
#endif
|
#endif
|
||||||
#if EPOLL
|
#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);
|
ospoll->epoll_fd = epoll_create1(EPOLL_CLOEXEC);
|
||||||
if (ospoll->epoll_fd < 0) {
|
if (ospoll->epoll_fd < 0) {
|
||||||
free (ospoll);
|
free (ospoll);
|
||||||
|
|
Loading…
Reference in New Issue