From 20f01f4a3d57bc4615cae4dfad74444233c40a58 Mon Sep 17 00:00:00 2001 From: Justin Maggard Date: Wed, 16 Sep 2009 18:04:10 +0000 Subject: [PATCH] * Make realpath() usage not depend on implementation-specific behavior. --- minidlna.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/minidlna.c b/minidlna.c index d903ca5..d1534e0 100644 --- a/minidlna.c +++ b/minidlna.c @@ -220,6 +220,7 @@ init(int argc, char * * argv) char * string, * word; enum media_types type; char * path; + char real_path[PATH_MAX]; char ext_ip_addr[INET_ADDRSTRLEN] = {'\0'}; /* first check if "-f" option is used */ @@ -325,18 +326,17 @@ init(int argc, char * * argv) type = IMAGES_ONLY; myval = index(ary_options[i].value, '/'); case '/': - path = realpath(myval ? myval:ary_options[i].value, NULL); + path = realpath(myval ? myval:ary_options[i].value, real_path); if( !path ) - path = strdup(myval ? myval:ary_options[i].value); + path = (myval ? myval:ary_options[i].value); if( access(path, F_OK) != 0 ) { fprintf(stderr, "Media directory not accessible! [%s]\n", path); - free(path); break; } struct media_dir_s * this_dir = calloc(1, sizeof(struct media_dir_s)); - this_dir->path = path; + this_dir->path = strdup(path); this_dir->type = type; if( !media_dirs ) {