From 68634537c043fae1f991302005c81f68a52a3eea Mon Sep 17 00:00:00 2001 From: Squibid Date: Fri, 25 Apr 2025 01:41:03 -0500 Subject: fix bug where XD would segfault if the cwd didn't exist also include errno so we can check it --- XD.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'XD.c') diff --git a/XD.c b/XD.c index df3d760..6a6500c 100644 --- a/XD.c +++ b/XD.c @@ -3,7 +3,10 @@ #include #include -#if defined(ERR) || defined(EXPLAIN) +#ifdef ERR +#include +#endif +#if defined(EXPLAIN) || defined(ERR) #include #endif @@ -62,9 +65,12 @@ char struct stat s; int i, c; - /* find the number of jumps to the root of the fs */ rpath = realpath(path, NULL); + if (!rpath) { + L("realpath: %s", strerror(errno)); + return NULL; + } for (i = c = 0; i < strlen(rpath); i++) { if (rpath[i] == '/') { c++; -- cgit v1.2.1