nnn

mirror of https://github.com/jarun/nnn
Log | Files | Refs | README | LICENSE

commit 4f43b5cea03e604e33222ab04f27f6392bd1f3db
parent 8db6abc2d844c0ddaf2f04d959e3c3f319b27a0e
Author: Arun Prakash Jana <engineerarun@gmail.com>
Date:   Sun,  9 Nov 2025 09:28:29 +0530

Handle access outside buffer

Diffstat:
Msrc/nnn.c | 5++---
1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/src/nnn.c b/src/nnn.c @@ -3683,7 +3683,7 @@ static char *xreadline(const char *prefill, const char *prompt) int x, r; const int WCHAR_T_WIDTH = sizeof(wchar_t); wint_t ch[1]; - wchar_t * const buf = malloc(sizeof(wchar_t) * READLINE_MAX); + wchar_t * const buf = malloc(sizeof(wchar_t) * (READLINE_MAX + 1)); // 1 element extra for handling full-width characters if (!buf) errexit(); @@ -3707,8 +3707,7 @@ static char *xreadline(const char *prefill, const char *prompt) while (1) { buf[len] = ' '; - if (len < (READLINE_MAX - 1)) - buf[len + 1] = ' '; // Handle full-width characters + buf[len + 1] = ' '; // Handle full-width characters attron(COLOR_PAIR(cfg.curctx + 1)); if (pos > (size_t)(xcols - x)) {