[vlc-devel] [PATCH 09/12] network: io: Remove VLA usages

Rémi Denis-Courmont remi at remlab.net
Tue Dec 8 16:12:36 CET 2020


Callers don't expect errors here. Polling just has to work.

-1

Le 8 décembre 2020 16:19:13 GMT+02:00, "Hugo Beauzée-Luyssen" <hugo at beauzee.fr> a écrit :
>---
> src/network/io.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
>diff --git a/src/network/io.c b/src/network/io.c
>index 5285edc169..d4f15fe115 100644
>--- a/src/network/io.c
>+++ b/src/network/io.c
>@@ -313,7 +313,9 @@ int net_Accept(vlc_object_t *obj, int *fds)
>     while (fds[n] != -1)
>         n++;
> 
>-    struct pollfd ufd[n];
>+    struct pollfd *ufd = malloc(n * sizeof((*ufd)));
>+    if (!ufd)
>+        return -1;
>     /* Initialize file descriptor set */
>     for (unsigned i = 0; i < n; i++)
>     {
>@@ -328,6 +330,7 @@ int net_Accept(vlc_object_t *obj, int *fds)
>             if (net_errno != EINTR)
>             {
>             msg_Err(obj, "poll error: %s", vlc_strerror_c(net_errno));
>+                free(ufd);
>                 return -1;
>             }
>         }
>@@ -359,9 +362,11 @@ int net_Accept(vlc_object_t *obj, int *fds)
>              */
>             memmove(fds + i, fds + i + 1, n - (i + 1));
>             fds[n - 1] = sfd;
>+            free(ufd);
>             return fd;
>         }
>     }
>+    free(ufd);
>     return -1;
> }
> 
>-- 
>2.29.2
>
>_______________________________________________
>vlc-devel mailing list
>To unsubscribe or modify your subscription options:
>https://mailman.videolan.org/listinfo/vlc-devel

-- 
Envoyé de mon appareil Android avec Courriel K-9 Mail. Veuillez excuser ma brièveté.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20201208/3aa76f43/attachment.html>


More information about the vlc-devel mailing list