From 6d9f4b37102aec9ae3e89fd9c0591d8b965d8f25 Mon Sep 17 00:00:00 2001 From: Arun Prakash Jana Date: Tue, 12 Feb 2019 08:52:31 +0530 Subject: [PATCH] Terminate string only once --- src/nnn.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/nnn.c b/src/nnn.c index 4016b012..52487a8a 100644 --- a/src/nnn.c +++ b/src/nnn.c @@ -1884,10 +1884,10 @@ static char *unescape(const char *str, uint maxcols) if (maxcols) { len = lencount = wcswidth(wbuf, len); - while (len > maxcols) { - wbuf[--lencount] = L'\0'; - len = wcswidth(wbuf, lencount); - } + while (len > maxcols) + len = wcswidth(wbuf, --lencount); + + wbuf[lencount] = L'\0'; } while (*buf) {