bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] isearch: fix with HANDLE_MULTIBYTE && LC_ALL=C


From: Grisha Levit
Subject: [PATCH] isearch: fix with HANDLE_MULTIBYTE && LC_ALL=C
Date: Fri, 18 Oct 2024 18:50:09 -0400

HISTFILE= INPUTRC=/ LC_ALL=C bash --norc -in <<< $'\cR.'

WARNING: MemorySanitizer: use-of-uninitialized-value
     #0 _rl_isearch_dispatch         isearch.c:745:31
     #1 rl_search_history            isearch.c:926:11
     #2 rl_reverse_search_history    isearch.c:135:11
     #3 _rl_dispatch_subseq          readline.c:941:8
---
 lib/readline/isearch.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/lib/readline/isearch.c b/lib/readline/isearch.c
index 9ddf9ce3..09e981e6 100644
--- a/lib/readline/isearch.c
+++ b/lib/readline/isearch.c
@@ -742,9 +742,11 @@ opcode_dispatch:
     /* Add character to search string and continue search. */
     default:
 #if defined (HANDLE_MULTIBYTE)
-      wlen = (cxt->mb[0] == 0 || cxt->mb[1] == 0) ? 1 : RL_STRLEN (cxt->mb);
+      if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
+       wlen = (cxt->mb[0] == 0 || cxt->mb[1] == 0) ? 1 : RL_STRLEN (cxt->mb);
+      else
 #else
-      wlen = 1;
+       wlen = 1;
 #endif
       if (cxt->search_string_index + wlen + 1 >= cxt->search_string_size)
        {
-- 
2.47.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]