[vlc-devel] [PATCH 02/12] actions: Avoid VLA

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


---
 src/misc/actions.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/misc/actions.c b/src/misc/actions.c
index b10b07936e..58bb64c3bc 100644
--- a/src/misc/actions.c
+++ b/src/misc/actions.c
@@ -601,12 +601,14 @@ size_t
 vlc_actions_get_keycodes(vlc_object_t *p_obj, const char *psz_key_name,
                         bool b_global, uint_fast32_t **pp_keycodes)
 {
-    char varname[12 /* "global-key-" */ + strlen( psz_key_name )];
-    sprintf( varname, "%skey-%s", b_global ? "global-" : "", psz_key_name );
+    char* varname;
+    if (asprintf(&varname, "%skey-%s", b_global ? "global-" : "", psz_key_name) < 0)
+        return 0;
 
     *pp_keycodes = NULL;
 
     char *psz_keys = var_InheritString( p_obj, varname );
+    free(varname);
     if( psz_keys == NULL )
         return 0;
 
-- 
2.29.2



More information about the vlc-devel mailing list