[vlc-devel] commit: Do not duplicate potentially NULL strings ( Rafaël Carré )

git version control git at videolan.org
Mon May 5 09:51:21 CEST 2008


vlc | branch: master | Rafaël Carré <funman at videolan.org> | Mon May  5 09:50:30 2008 +0200| [99fec92fb8d61c7702006db41f5ab7dfd6111e5b]

Do not duplicate potentially NULL strings

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=99fec92fb8d61c7702006db41f5ab7dfd6111e5b
---

 src/config/core.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/config/core.c b/src/config/core.c
index b114cb9..28aea7d 100644
--- a/src/config/core.c
+++ b/src/config/core.c
@@ -740,7 +740,8 @@ static char *config_GetFooDir (const char *xdg_name, const char *xdg_default)
 
     /* XDG Base Directory Specification - Version 0.6 */
     snprintf (var, sizeof (var), "XDG_%s_HOME", xdg_name);
-    psz_env = FromLocaleDup (getenv (var));
+    char *psz_home = getenv( var );
+    psz_env = psz_home ? FromLocaleDup( psz_home ) : NULL;
     if( psz_env )
     {
         if( asprintf( &psz_dir, "%s/vlc", psz_env ) == -1 )
@@ -748,7 +749,8 @@ static char *config_GetFooDir (const char *xdg_name, const char *xdg_default)
         goto out;
     }
 
-    psz_env = FromLocaleDup (getenv ("HOME"));
+    psz_home = getenv( "HOME" );
+    psz_env = psz_home ? FromLocaleDup( psz_home ) : NULL;
     /* not part of XDG spec but we want a sensible fallback */
     if( !psz_env )
         psz_env = config_GetHomeDir();




More information about the vlc-devel mailing list