From 3706edb4f0fd07dbbea6bc68d7b90c0a7b86b63a Mon Sep 17 00:00:00 2001 From: =?utf8?q?R=C3=A9mi=20Denis-Courmont?= Date: Tue, 6 Mar 2018 21:24:27 +0200 Subject: [PATCH] posix: handle non-NULL filename with environment-based directories --- src/posix/dirs.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/posix/dirs.c b/src/posix/dirs.c index 280a37b2a7..2fccd229d5 100644 --- a/src/posix/dirs.c +++ b/src/posix/dirs.c @@ -57,8 +57,14 @@ char *config_GetSysPath(vlc_sysdir_t type, const char *filename) const char *name = env_vars[type]; if (*name != '\0') { const char *value = getenv(name); - if (value != NULL) - return strdup(value); + if (value != NULL) { + const char *fmt = (filename != NULL) ? "%s/%s" : "%s"; + char *filepath; + + if (unlikely(asprintf(&filepath, fmt, value, filename) == -1)) + filepath = NULL; + return filepath; + } } } -- 2.11.4.GIT