commit 13813a61a3680c490e9e0e533e5a4ae31443d107
parent 2f07ccdf21e705377862e5f9dfa31e1694979ac7
Author: Arun Prakash Jana <engineerarun@gmail.com>
Date: Tue, 18 Nov 2025 18:55:24 +0530
Fix #2093: Potential NULL Pointer Derefernce caused by missing check the return value of getcwd
Diffstat:
1 file changed, 4 insertions(+), 0 deletions(-)
diff --git a/src/nnn.c b/src/nnn.c
@@ -5258,6 +5258,8 @@ static bool handle_archive(char *fpath /* in-out param */, char op)
}
/* Copy the new dir path to open it in smart context */
outdir = getcwd(NULL, 0); // NOLINT
+ if (!outdir)
+ return FALSE;
x_to = TRUE;
}
}
@@ -7315,6 +7317,8 @@ static bool browse(char *ipath, int pkey)
if (g_state.initfile) {
free(initpath);
initpath = ipath = getcwd(NULL, 0); // NOLINT
+ if (!initpath)
+ return FALSE;
}
path = g_ctx[0].c_path; /* current directory */