]> Sergey Matveev's repositories - nnn.git/commitdiff
Free readline buffer in corner cases
authorArun Prakash Jana <engineerarun@gmail.com>
Fri, 12 Apr 2019 14:36:29 +0000 (20:06 +0530)
committerArun Prakash Jana <engineerarun@gmail.com>
Fri, 12 Apr 2019 14:36:29 +0000 (20:06 +0530)
src/nnn.c

index 043ee5b5d25d14a6c8b2057d350c8d808e3d9ad3..67ebdf1a201c913b2d33342d7e3211d384bcf2a3 100644 (file)
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -3830,6 +3830,8 @@ nochange:
 
                                        if (chdir(ipath) == -1) {
                                                printwarn();
+                                               if (tmp)
+                                                       free(tmp);
                                                goto nochange;
                                        }
 
@@ -3839,8 +3841,10 @@ nochange:
                                                spawn(shell, "-c", tmp, path, F_CLI);
                                                /* readline finishing touches */
                                                add_history(tmp);
-                                               free(tmp);
                                        }
+
+                                       if (tmp)
+                                               free(tmp);
                                }
 #endif
                        }