bug-readline
[Top][All Lists]
Advanced

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

Re: [PATCH] do-lowercase-version for non-uppercase chars


From: Grisha Levit
Subject: Re: [PATCH] do-lowercase-version for non-uppercase chars
Date: Thu, 30 Nov 2023 00:20:00 -0500

On Tue, May 30, 2023, 10:43 Chet Ramey <chet.ramey@case.edu> wrote:
>
> On 5/27/23 3:04 PM, Grisha Levit wrote:
> > If do-lowercase-version is bound to a key that is either not an uppercase
> > character or is a character that is its own lowercase version, then
> > readline will either loop forever with no way to interrupt (if the compiler
> > optimized out the recursion) or will exceed the stack depth and segfault.
>
> This sounds more like a "my arm hurts when I do that" kind of situation,
> but readline still shouldn't crash.

One more for completeness:

    $ bind '"ab": "c"' '"a": do-lowercase-version'
    $ ax
    Segmentation fault
---
diff --git a/lib/readline/readline.c b/lib/readline/readline.c
 index 608c65ec..bbec137d 100644
 --- a/lib/readline/readline.c
 +++ b/lib/readline/readline.c
 @@ -1124,7 +1124,11 @@ _rl_subseq_result (int r, Keymap map, int key,
int got_subseq)
        type = m[ANYOTHERKEY].type;
        func = m[ANYOTHERKEY].function;
        if (type == ISFUNC && func == rl_do_lowercase_version)
 -      r = _rl_dispatch (_rl_to_lower ((unsigned char)key), map);
 +      {
 +        int newkey = _rl_to_lower (key);
 +        r = (newkey != key) ? _rl_dispatch (newkey, map)
 +                            : 1;      /* avoid infinite recursion */
 +      }
        else if (type == ISFUNC)
        {
          /* If we shadowed a function, whatever it is, we somehow need a



reply via email to

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