summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSquibid <me@zacharyscheiman.com>2025-04-25 01:41:03 -0500
committerSquibid <me@zacharyscheiman.com>2025-04-25 02:33:02 -0500
commit68634537c043fae1f991302005c81f68a52a3eea (patch)
tree1faaf0ba0280404663b556693586ebd6f154cce6
parent529ac333ea1a459860641a874e7e6d25bc6d000a (diff)
downloadXD-68634537c043fae1f991302005c81f68a52a3eea.tar.gz
XD-68634537c043fae1f991302005c81f68a52a3eea.tar.bz2
XD-68634537c043fae1f991302005c81f68a52a3eea.zip
fix bug where XD would segfault if the cwd didn't exist
also include errno so we can check it
Diffstat (limited to '')
-rw-r--r--XD.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/XD.c b/XD.c
index df3d760..6a6500c 100644
--- a/XD.c
+++ b/XD.c
@@ -3,7 +3,10 @@
#include <string.h>
#include <ctype.h>
-#if defined(ERR) || defined(EXPLAIN)
+#ifdef ERR
+#include <errno.h>
+#endif
+#if defined(EXPLAIN) || defined(ERR)
#include <stdarg.h>
#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++;