[vlc-commits] posix: handle non-NULL filename with environment-based directories
Rémi Denis-Courmont
git at videolan.org
Tue Mar 6 20:25:00 CET 2018
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Tue Mar 6 21:24:27 2018 +0200| [3706edb4f0fd07dbbea6bc68d7b90c0a7b86b63a] | committer: Rémi Denis-Courmont
posix: handle non-NULL filename with environment-based directories
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=3706edb4f0fd07dbbea6bc68d7b90c0a7b86b63a
---
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;
+ }
}
}
More information about the vlc-commits
mailing list