Till Wegmüller
2024-04-07 6ca8c2ef2bffdfec8cc95c049ac3f2230dc6ca82
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# DP: readline63-002 upstream patch
 
               READLINE PATCH REPORT
               =====================
 
Readline-Release: 6.3
Patch-ID: readline63-002
 
Bug-Reported-by:    Anatol Pomozov <anatol.pomozov@gmail.com>
Bug-Reference-ID:    <CAOMFOmXy3mT2So5GQ5F-smCVArQuAeBwZ2QKzgCtMeXJoDeYOQ@mail.gmail.com>
Bug-Reference-URL:    http://lists.gnu.org/archive/html/bug-readline/2014-03/msg00010.html
 
Bug-Description:
 
When in callback mode, some readline commands can cause readline to seg
fault by passing invalid contexts to callback functions.
 
Patch (apply with `patch -p0'):
 
Index: b/readline.c
===================================================================
--- a/readline.c
+++ b/readline.c
@@ -744,7 +744,8 @@ _rl_dispatch_callback (cxt)
     r = _rl_subseq_result (r, cxt->oldmap, cxt->okey, (cxt->flags & KSEQ_SUBSEQ));
 
   RL_CHECK_SIGNALS ();
-  if (r == 0)            /* success! */
+  /* We only treat values < 0 specially to simulate recursion. */
+  if (r >= 0 || (r == -1 && (cxt->flags & KSEQ_SUBSEQ) == 0))    /* success! or failure! */
     {
       _rl_keyseq_chain_dispose ();
       RL_UNSETSTATE (RL_STATE_MULTIKEY);