src/nnn.c | 4 +++- diff --git a/src/nnn.c b/src/nnn.c index 13d9815cb9c5da05870c08fd0e7caf57ffd3723c..069599b3e18a4dfbf45d8e1f88a23a5f31d1d9f9 100644 --- a/src/nnn.c +++ b/src/nnn.c @@ -4236,7 +4236,9 @@ if (listpath) { DPRINTF_S(__FUNCTION__); DPRINTF_S(listpath); spawn("rm -rf", listpath, NULL, NULL, F_NOTRACE | F_MULTI); - free(listpath); + /* Do not free if program was started in list mode */ + if (listpath != initpath) + free(listpath); listpath = NULL; } }