diff options
| author | Konstantin Belousov <kib@FreeBSD.org> | 2010-04-20 14:22:29 +0000 | 
|---|---|---|
| committer | Konstantin Belousov <kib@FreeBSD.org> | 2010-04-20 14:22:29 +0000 | 
| commit | 655c8a600bb02846e05f137609abb62134a13a26 (patch) | |
| tree | dce701aa8168a183deb7c45c488c88033d3a2c76 /lib/libc/stdlib/realpath.c | |
| parent | 0a2d5fea5921acbf8945307784cf6e4b7924a95a (diff) | |
Notes
Diffstat (limited to 'lib/libc/stdlib/realpath.c')
| -rw-r--r-- | lib/libc/stdlib/realpath.c | 18 | 
1 files changed, 5 insertions, 13 deletions
| diff --git a/lib/libc/stdlib/realpath.c b/lib/libc/stdlib/realpath.c index 31c93e677418..e75ee4ac823a 100644 --- a/lib/libc/stdlib/realpath.c +++ b/lib/libc/stdlib/realpath.c @@ -84,12 +84,10 @@ realpath(const char * __restrict path, char * __restrict resolved)  		left_len = strlcpy(left, path + 1, sizeof(left));  	} else {  		if (getcwd(resolved, PATH_MAX) == NULL) { -			strlcpy(resolved, ".", PATH_MAX); -			if (m) { -				serrno = errno; +			if (m)  				free(resolved); -				errno = serrno; -			} +			else +				strlcpy(resolved, ".", PATH_MAX);  			return (NULL);  		}  		resolved_len = strlen(resolved); @@ -168,11 +166,8 @@ realpath(const char * __restrict path, char * __restrict resolved)  				errno = serrno;  				return (resolved);  			} -			if (m) { -				serrno = errno; +			if (m)  				free(resolved); -				errno = serrno; -			}  			return (NULL);  		}  		if (S_ISLNK(sb.st_mode)) { @@ -184,11 +179,8 @@ realpath(const char * __restrict path, char * __restrict resolved)  			}  			slen = readlink(resolved, symlink, sizeof(symlink) - 1);  			if (slen < 0) { -				if (m) { -					serrno = errno; +				if (m)  					free(resolved); -					errno = serrno; -				}  				return (NULL);  			}  			symlink[slen] = '\0'; | 
