]> Sergey Matveev's repositories - nnn.git/commitdiff
Fix calculation of remaining copybuf bytes
authorArun Prakash Jana <engineerarun@gmail.com>
Sat, 14 Apr 2018 14:26:04 +0000 (19:56 +0530)
committerArun Prakash Jana <engineerarun@gmail.com>
Sat, 14 Apr 2018 15:10:07 +0000 (20:40 +0530)
Start with PATH_MAX bytes and then double each time.

nnn.c

diff --git a/nnn.c b/nnn.c
index 25a1c8cc453cbde1cc2117b36ec8c8657bf62cb9..e25e7c69de4360d1dce3d67bde2a4f50a34dff24 100644 (file)
--- a/nnn.c
+++ b/nnn.c
@@ -642,7 +642,7 @@ writecp(const char *buf, const size_t buflen)
 static bool
 appendfilepath(const char *path, const size_t len)
 {
-       if ((copybufpos >= copybuflen) || (len > (copybuflen - (copybufpos + 3)))) {
+       if ((copybufpos >= copybuflen) || ((len + 3) > (copybuflen - copybufpos))) {
                copybuflen += PATH_MAX;
                pcopybuf = xrealloc(pcopybuf, copybuflen);
                if (!pcopybuf) {
@@ -3055,7 +3055,6 @@ nochange:
                                                writecp(pcopybuf, copybufpos - 1); /* Truncate NULL from end */
                                        else
                                                spawn(copier, pcopybuf, NULL, NULL, F_NOTRACE);
-                                       DPRINTF_S(pcopybuf);
                                        if (!len)
                                                printmsg("files copied");
                                } else