[vlc-devel] [PATCH 05/12] misc: message: Remove VLA usage

Hugo Beauzée-Luyssen hugo at beauzee.fr
Tue Dec 8 15:19:09 CET 2020


---
 src/misc/messages.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/misc/messages.c b/src/misc/messages.c
index 898e4be56f..7e5bcc00e3 100644
--- a/src/misc/messages.c
+++ b/src/misc/messages.c
@@ -95,9 +95,12 @@ void vlc_vaLog(struct vlc_logger *const *loggerp, int type,
     p = strchr(module, '.');
 
     size_t modlen = (p != NULL) ? (p - module) : 0;
-    char modulebuf[modlen + 1];
+    char *modulebuf = NULL;
     if (p != NULL)
     {
+        modulebuf = malloc(modlen + 1);
+        if (!modulebuf)
+            return;
         memcpy(modulebuf, module, modlen);
         modulebuf[modlen] = '\0';
         module = modulebuf;
@@ -126,6 +129,7 @@ void vlc_vaLog(struct vlc_logger *const *loggerp, int type,
     /* Pass message to the callback */
     if (logger != NULL)
         vlc_vaLogCallback(logger, type, &msg, format, args);
+    free(modulebuf);
 }
 
 void vlc_Log(struct vlc_logger *const *logger, int type,
-- 
2.29.2



More information about the vlc-devel mailing list