]> git.sesse.net Git - vlc/blobdiff - src/config/dirs.c
config_PutPsz: fix potential use-after-free
[vlc] / src / config / dirs.c
index d490975f5aefe596bf5d5b8338f66fcd2b31ba20..22a5bdcab54f9fa0c4a07a7a50abebc1d45a96bf 100644 (file)
 
 #include "configuration.h"
 
+#undef config_GetDataDir
 /**
- * Determines the shared data directory
+ * Determines the shared architecture-independent data directory
  *
- * @return a string (always succeeds). Needs to be freed.
+ * @return a string or NULL. Use free() to release.
  */
-char *__config_GetDataDir( vlc_object_t *p_obj )
+char *config_GetDataDir( vlc_object_t *p_obj )
 {
-    char *psz_path = config_GetPsz( p_obj, "data-path" );
-    if( psz_path && *psz_path )
-        return psz_path;
-    free( psz_path );
-    return strdup( config_GetDataDirDefault() );
+    char *psz_path = var_InheritString( p_obj, "data-path" );
+    return psz_path ? psz_path : config_GetDataDirDefault();
 }