From 22111533d32a30dd52d51a7264c67f8afc7a6bd7 Mon Sep 17 00:00:00 2001 From: cbdev Date: Sat, 3 Jul 2021 19:58:47 +0200 Subject: Fix Coverity CID 371696 --- core/core.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/core/core.c b/core/core.c index 8554f03..415cfc3 100644 --- a/core/core.c +++ b/core/core.c @@ -109,6 +109,9 @@ MM_API int mm_manage_fd(int new_fd, char* back, int manage, void* impl){ if(u == fds.n){ fds.fd = realloc(fds.fd, (fds.n + 1) * sizeof(managed_fd)); if(!fds.fd){ + free(fds.signaled); + fds.signaled = NULL; + fds.n = 0; LOG("Failed to allocate memory"); return 1; } @@ -116,6 +119,9 @@ MM_API int mm_manage_fd(int new_fd, char* back, int manage, void* impl){ fds.signaled = realloc(fds.signaled, (fds.n + 1) * sizeof(managed_fd)); if(!fds.signaled){ LOG("Failed to allocate memory"); + free(fds.fd); + fds.fd = NULL; + fds.n = 0; return 1; } fds.n++; @@ -179,7 +185,7 @@ int core_iteration(){ #endif //rebuild fd set if necessary - if(fd_set_dirty || !fds.signaled){ + if(fd_set_dirty){ fds.read = core_collect(&(fds.max)); fd_set_dirty = 0; } -- cgit v1.2.3