[vlc-devel] [PATCH 12/12] lib: core: Don't use VLAs
Hugo Beauzée-Luyssen
hugo at beauzee.fr
Tue Dec 8 15:19:16 CET 2020
---
lib/core.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/lib/core.c b/lib/core.c
index 3bd3292e24..b3f6418bf4 100644
--- a/lib/core.c
+++ b/lib/core.c
@@ -43,7 +43,9 @@ libvlc_instance_t * libvlc_new( int argc, const char *const *argv )
if (unlikely(p_new == NULL))
return NULL;
- const char *my_argv[argc + 2];
+ const char **my_argv = malloc((argc + 2) * sizeof(*my_argv));
+ if (unlikely(my_argv == NULL))
+ goto error;
my_argv[0] = "libvlc"; /* dummy arg0, skipped by getopt() et al */
for( int i = 0; i < argc; i++ )
my_argv[i + 1] = argv[i];
@@ -62,9 +64,11 @@ libvlc_instance_t * libvlc_new( int argc, const char *const *argv )
p_new->p_libvlc_int = p_libvlc_int;
vlc_atomic_rc_init( &p_new->ref_count );
p_new->p_callback_list = NULL;
+ free(my_argv);
return p_new;
error:
+ free(my_argv);
free (p_new);
libvlc_threads_deinit ();
return NULL;
--
2.29.2
More information about the vlc-devel
mailing list