From 5af408ce2fd423dc9a9f8c91576a6a9dc52e16a1 Mon Sep 17 00:00:00 2001 From: Elena Zannoni Date: Tue, 27 Jan 2004 22:25:15 +0000 Subject: 2004-01-27 Elena Zannoni Merge in official patches to readline-4.3 from ftp://ftp.cwru.edu/pub/bash/readline-4.3-patches: NOTE: Patch-ID readline-43-004 was already applied (see below). * bind.c (rl_generic_bind): Pressing certain key sequences causes an infinite loop in _rl_dispatch_subseq with the `key' argument set to 256. This eventually causes bash to exceed the stack size limit and crash with a segmentation violation. Patch-ID: readline43-001. * readline.c (_rl_dispatch_subseq): Repeating an edit in vi-mode with `.' does not work. Patch-ID: readline43-002. * mbutil.c (_rl_get_char_len, _rl_compare_chars, _rl_adjust_point): When in a locale with multibyte characters, the readline display updater will occasionally cause a segmentation fault when attempting to compute the length of the first multibyte character on the line. Patch-ID: readline43-003. * vi_mode.c (_rl_vi_change_mbchar_case): Using the vi editing mode's case-changing commands in a locale with multibyte characters will cause garbage characters to be inserted into the editing buffer. Patch-ID: readline43-005. --- readline/mbutil.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'readline/mbutil.c') diff --git a/readline/mbutil.c b/readline/mbutil.c index 50302f0..8794d02 100644 --- a/readline/mbutil.c +++ b/readline/mbutil.c @@ -205,14 +205,16 @@ _rl_get_char_len (src, ps) if (tmp == (size_t)(-2)) { /* shorted to compose multibyte char */ - memset (ps, 0, sizeof(mbstate_t)); + if (ps) + memset (ps, 0, sizeof(mbstate_t)); return -2; } else if (tmp == (size_t)(-1)) { /* invalid to compose multibyte char */ /* initialize the conversion state */ - memset (ps, 0, sizeof(mbstate_t)); + if (ps) + memset (ps, 0, sizeof(mbstate_t)); return -1; } else if (tmp == (size_t)0) @@ -225,9 +227,12 @@ _rl_get_char_len (src, ps) return 1. Otherwise return 0. */ int _rl_compare_chars (buf1, pos1, ps1, buf2, pos2, ps2) - char *buf1, *buf2; - mbstate_t *ps1, *ps2; - int pos1, pos2; + char *buf1; + int pos1; + mbstate_t *ps1; + char *buf2; + int pos2; + mbstate_t *ps2; { int i, w1, w2; @@ -276,8 +281,11 @@ _rl_adjust_point(string, point, ps) pos++; /* clear the state of the byte sequence, because in this case effect of mbstate is undefined */ - memset (ps, 0, sizeof (mbstate_t)); + if (ps) + memset (ps, 0, sizeof (mbstate_t)); } + else if (tmp == 0) + pos++; else pos += tmp; } -- cgit v1.1