[vlc-devel] [PATCH 10/12] preparser: art: Use strdup instead of a VLA

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


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

diff --git a/src/preparser/art.c b/src/preparser/art.c
index b7f0d48411..c3a20836cd 100644
--- a/src/preparser/art.c
+++ b/src/preparser/art.c
@@ -39,8 +39,9 @@
 
 static void ArtCacheCreateDir( const char *psz_dir )
 {
-    char newdir[strlen( psz_dir ) + 1];
-    strcpy( newdir, psz_dir );
+    char* newdir = strdup(psz_dir);
+    if( !newdir )
+        return;
     char * psz_newdir = newdir;
     char * psz = psz_newdir;
 
@@ -55,6 +56,7 @@ static void ArtCacheCreateDir( const char *psz_dir )
         psz++;
     }
     vlc_mkdir( psz_dir, 0700 );
+    free(newdir);
 }
 
 static char* ArtCacheGetDirPath( const char *psz_arturl, const char *psz_artist,
-- 
2.29.2



More information about the vlc-devel mailing list