[vlc-devel] [PATCH] darwin/dirs: validate rc of asprint()

Arjun Sreedharan arjun024 at gmail.com
Sat Apr 25 02:09:10 CEST 2015


When asprintf() fails, @path is undefined.

Signed-off-by: Arjun Sreedharan <arjun024 at gmail.com>
---
 src/darwin/dirs.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/darwin/dirs.c b/src/darwin/dirs.c
index 9c34cc5..7b6cedf 100644
--- a/src/darwin/dirs.c
+++ b/src/darwin/dirs.c
@@ -82,9 +82,10 @@ char *config_GetLibDir (void)
     if (dladdr(system_Init, &info)) {
         char *incompletepath = strdup(dirname( (char *)info.dli_fname ));
         char *path = NULL;
-        asprintf(&path, "%s/"PACKAGE, incompletepath);
+        if(asprintf(&path, "%s/"PACKAGE, incompletepath) == -1)
+            path = NULL;
         free(incompletepath);
-        return path;
+        return (path != NULL) ? path : strdup (PKGLIBDIR);
     }
 
     /* should never happen */
-- 
1.7.11.7




More information about the vlc-devel mailing list