fix bug where XD would segfault if the cwd didn't exist
also include errno so we can check it
This commit is contained in:
10
XD.c
10
XD.c
@ -3,7 +3,10 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
#if defined(ERR) || defined(EXPLAIN)
|
#ifdef ERR
|
||||||
|
#include <errno.h>
|
||||||
|
#endif
|
||||||
|
#if defined(EXPLAIN) || defined(ERR)
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -62,9 +65,12 @@ char
|
|||||||
struct stat s;
|
struct stat s;
|
||||||
int i, c;
|
int i, c;
|
||||||
|
|
||||||
|
|
||||||
/* find the number of jumps to the root of the fs */
|
/* find the number of jumps to the root of the fs */
|
||||||
rpath = realpath(path, NULL);
|
rpath = realpath(path, NULL);
|
||||||
|
if (!rpath) {
|
||||||
|
L("realpath: %s", strerror(errno));
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
for (i = c = 0; i < strlen(rpath); i++) {
|
for (i = c = 0; i < strlen(rpath); i++) {
|
||||||
if (rpath[i] == '/') {
|
if (rpath[i] == '/') {
|
||||||
c++;
|
c++;
|
||||||
|
Reference in New Issue
Block a user