[vlc-devel] [PATCH 11/12] config: file: Don't use VLAs
Hugo Beauzée-Luyssen
hugo at beauzee.fr
Tue Dec 8 15:19:15 CET 2020
---
src/config/file.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/src/config/file.c b/src/config/file.c
index ae6e8b9ce5..793083c86a 100644
--- a/src/config/file.c
+++ b/src/config/file.c
@@ -282,8 +282,10 @@ int config_CreateDir( vlc_object_t *p_this, const char *psz_dirname )
case ENOENT:
{
/* Let's try to create the parent directory */
- char psz_parent[strlen( psz_dirname ) + 1], *psz_end;
- strcpy( psz_parent, psz_dirname );
+ char *psz_parent = strdup(psz_dirname);
+ if (!psz_parent)
+ break;
+ char *psz_end;
psz_end = strrchr( psz_parent, DIR_SEP_CHAR );
if( psz_end && psz_end != psz_parent )
@@ -292,9 +294,13 @@ int config_CreateDir( vlc_object_t *p_this, const char *psz_dirname )
if( config_CreateDir( p_this, psz_parent ) == 0 )
{
if( !vlc_mkdir( psz_dirname, 0700 ) )
+ {
+ free(psz_parent);
return 0;
+ }
}
}
+ free(psz_parent);
}
}
--
2.29.2
More information about the vlc-devel
mailing list