bug-bash
[Top][All Lists]
Advanced

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

Re: crash inserting character before a special and a normal one


From: Tobias Rittweiler
Subject: Re: crash inserting character before a special and a normal one
Date: Thu, 17 Apr 2003 19:06:59 +0200

On Thursday, April 17, 2003 at 6:54:40 PM, 
    Philippe Biondi <address@hidden> wrote:

> > Try the patch from
> >         http://mail.gnu.org/archive/html/bug-bash/2003-04/msg00026.html
>
> -      memset (ps, 0, sizeof(mbstate_t));
> +      if (ps != NULL) memset (ps, 0, sizeof(mbstate_t));
>
> That will fix the problem. But is it normal for "ps" to be null here ?
> I could not determine that as I can't match my sources with the binary
> verion I have.

Well, firstly mbrlen(3) says:
        If ps is a NULL pointer, a static anonymous state only known
        to the mbrlen function is used instead.
That means, mbrlen _can_ work with passing a NULL pointer as ps --
readline can't deny that and just assume ps is never NULL. Well,
actually it could do that, but that wouldn't be good programming
practise, imho. :-)

And second, the source of update_line() (in display.c) is as follows:

1206 #if defined (HANDLE_MULTIBYTE)
1207   /* This may not work for stateful encoding, but who cares? To handle
1208      stateful encoding properly, we have to scan each string from the
1209      beginning and compare. */
1210   else if (_rl_compare_chars (ols, 0, NULL, nls, 0, NULL) == 0)
1211 #else
1212   else if (*ols != *nls)
1213 #endif

Purpose is to test whether ols isn't equal to nls, and it's the
correct way to pass NULL as ps in this circumstance, asfaics.


-- 
cheers,
 Tobias                                       

http://freebits.org  - ``Free Life, free Opinion, free Software.''
http://rocklinux.org - ``I'm a hacker, and I'm using ROCK Linux.''

In large states public education will always be mediocre, for the same reason 
that in large kitchens the cooking is usually bad. 
  -- Friedrich Nietzsche





reply via email to

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