]>
Commit | Line | Data |
---|---|---|
3a58abaf AM |
1 | Fix Valgrind paste of >= 256 * (screen width) characters (as 130001). |
2 | ||
3 | Invalid write of size 4 | |
4 | at 0x8203BD9: rl_redisplay (display.c:812) | |
5 | by 0x81F5130: _rl_internal_char_cleanup (readline.c:427) | |
6 | by 0x81F52B3: readline_internal_char (readline.c:508) | |
7 | by 0x8209817: rl_callback_read_char (callback.c:184) | |
8 | by 0x8135312: rl_callback_read_char_wrapper (event-top.c:179) | |
9 | by 0x8135B7B: stdin_event_handler (event-top.c:432) | |
10 | by 0x81349F2: handle_file_event (event-loop.c:730) | |
11 | by 0x81342AB: process_event (event-loop.c:343) | |
12 | by 0x81342F4: gdb_do_one_event (event-loop.c:380) | |
13 | by 0x81313AC: catch_errors (exceptions.c:515) | |
14 | by 0x80CE8CA: tui_command_loop (tui-interp.c:151) | |
15 | by 0x81318B9: current_interp_command_loop (interps.c:278) | |
16 | Address 0x43DCEB8 is 0 bytes after a block of size 1,024 alloc'd | |
17 | at 0x4005400: malloc (vg_replace_malloc.c:149) | |
18 | by 0x8087084: xmalloc (utils.c:959) | |
19 | by 0x8202CA7: init_line_structures (display.c:440) | |
20 | by 0x8202D14: rl_redisplay (display.c:471) | |
21 | by 0x81F4F53: readline_internal_setup (readline.c:363) | |
22 | by 0x820958C: _rl_callback_newline (callback.c:89) | |
23 | by 0x82095BB: rl_callback_handler_install (callback.c:101) | |
24 | by 0x80CE896: tui_command_loop (tui-interp.c:138) | |
25 | by 0x81318B9: current_interp_command_loop (interps.c:278) | |
26 | by 0x807E69A: captured_command_loop (main.c:101) | |
27 | by 0x81313AC: catch_errors (exceptions.c:515) | |
28 | by 0x807F55A: captured_main (main.c:826) | |
29 | ||
30 | ||
31 | 2006-11-08 Jan Kratochvil <jan.kratochvil@redhat.com> | |
32 | ||
33 | * readline/display.c (line_state, line_state_array, line_state_visible, | |
34 | line_state_invisible): Encapsulate _rl_wrapped_line, inv_lbreaks, | |
35 | inv_lbsize, vis_lbreaks, vis_lbsize, visible_line, invisible_line. | |
36 | (init_line_structures): Initialize both _rl_wrapped_line ones now. | |
37 | (rl_redisplay): Fix _rl_wrapped_line handling by using its own size. | |
38 | Swap whole `line_state_visible' / `line_state_invisible' structures. | |
39 | (update_line): Update for new `_rl_wrapped_line'. | |
40 | ||
41 | ||
42 | Index: ./readline/display.c | |
43 | =================================================================== | |
44 | --- ./readline/display.c 5 May 2006 18:26:12 -0000 1.11 | |
45 | +++ ./readline/display.c 8 Nov 2006 18:23:33 -0000 | |
46 | @@ -73,15 +73,31 @@ static void delete_chars PARAMS((int)); | |
47 | static void insert_some_chars PARAMS((char *, int, int)); | |
48 | static void cr PARAMS((void)); | |
49 | ||
50 | +struct line_state | |
51 | + { | |
52 | + char *line; | |
53 | + int *lbreaks; | |
54 | + int lbreaks_size; | |
55 | +#if defined (HANDLE_MULTIBYTE) | |
56 | + int *wrapped_line; | |
57 | + int wrapped_line_size; | |
58 | +#endif | |
59 | + }; | |
60 | +static struct line_state line_state_array[2]; | |
61 | +static struct line_state *line_state_visible = &line_state_array[0]; | |
62 | +static struct line_state *line_state_invisible = &line_state_array[1]; | |
63 | + | |
64 | #if defined (HANDLE_MULTIBYTE) | |
65 | static int _rl_col_width PARAMS((const char *, int, int)); | |
66 | -static int *_rl_wrapped_line; | |
67 | #else | |
68 | # define _rl_col_width(l, s, e) (((e) <= (s)) ? 0 : (e) - (s)) | |
69 | #endif | |
70 | ||
71 | -static int *inv_lbreaks, *vis_lbreaks; | |
72 | -static int inv_lbsize, vis_lbsize; | |
73 | +/* FIXME: Backward compatible naming. */ | |
74 | +#define inv_lbreaks (line_state_invisible->lbreaks) | |
75 | +#define inv_lbsize (line_state_invisible->lbreaks_size) | |
76 | +#define vis_lbreaks (line_state_visible->lbreaks) | |
77 | +#define vis_lbsize (line_state_visible->lbreaks_size) | |
78 | ||
79 | /* Heuristic used to decide whether it is faster to move from CUR to NEW | |
80 | by backing up or outputting a carriage return and moving forward. */ | |
81 | @@ -150,8 +166,9 @@ static int last_lmargin; | |
82 | ||
83 | /* The line display buffers. One is the line currently displayed on | |
84 | the screen. The other is the line about to be displayed. */ | |
85 | -static char *visible_line = (char *)NULL; | |
86 | -static char *invisible_line = (char *)NULL; | |
87 | +/* FIXME: Backward compatible naming. */ | |
88 | +#define visible_line (line_state_visible->line) | |
89 | +#define invisible_line (line_state_invisible->line) | |
90 | ||
91 | /* A buffer for `modeline' messages. */ | |
92 | static char msg_buf[128]; | |
93 | @@ -437,7 +454,10 @@ init_line_structures (minsize) | |
94 | inv_lbreaks = (int *)xmalloc (inv_lbsize * sizeof (int)); | |
95 | vis_lbreaks = (int *)xmalloc (vis_lbsize * sizeof (int)); | |
96 | #if defined (HANDLE_MULTIBYTE) | |
97 | - _rl_wrapped_line = (int *)xmalloc (vis_lbsize * sizeof (int)); | |
98 | + line_state_visible->wrapped_line_size = vis_lbsize; | |
99 | + line_state_visible->wrapped_line = (int *)xmalloc (line_state_visible->wrapped_line_size * sizeof (int)); | |
100 | + line_state_invisible->wrapped_line_size = inv_lbsize; | |
101 | + line_state_invisible->wrapped_line = (int *)xmalloc (line_state_invisible->wrapped_line_size * sizeof (int)); | |
102 | #endif | |
103 | inv_lbreaks[0] = vis_lbreaks[0] = 0; | |
104 | } | |
105 | @@ -572,10 +592,15 @@ rl_redisplay () | |
106 | { \ | |
107 | inv_lbsize *= 2; \ | |
108 | inv_lbreaks = (int *)xrealloc (inv_lbreaks, inv_lbsize * sizeof (int)); \ | |
109 | - _rl_wrapped_line = (int *)xrealloc (_rl_wrapped_line, inv_lbsize * sizeof (int)); \ | |
110 | } \ | |
111 | inv_lbreaks[++newlines] = out; \ | |
112 | - _rl_wrapped_line[newlines] = _rl_wrapped_multicolumn; \ | |
113 | + if (newlines >= (line_state_invisible->wrapped_line_size - 1)) \ | |
114 | + { \ | |
115 | + line_state_invisible->wrapped_line_size *= 2; \ | |
116 | + line_state_invisible->wrapped_line = (int *)xrealloc (line_state_invisible->wrapped_line, \ | |
117 | + line_state_invisible->wrapped_line_size * sizeof (int)); \ | |
118 | + } \ | |
119 | + line_state_invisible->wrapped_line[newlines] = _rl_wrapped_multicolumn; \ | |
120 | lpos = 0; \ | |
121 | } \ | |
122 | } while (0) | |
123 | @@ -605,7 +630,7 @@ rl_redisplay () | |
124 | #endif | |
125 | ||
126 | #if defined (HANDLE_MULTIBYTE) | |
127 | - memset (_rl_wrapped_line, 0, vis_lbsize); | |
128 | + memset (line_state_invisible->wrapped_line, 0, line_state_invisible->wrapped_line_size * sizeof (int)); | |
129 | num = 0; | |
130 | #endif | |
131 | ||
132 | @@ -1118,17 +1143,10 @@ rl_redisplay () | |
133 | ||
134 | /* Swap visible and non-visible lines. */ | |
135 | { | |
136 | - char *vtemp = visible_line; | |
137 | - int *itemp = vis_lbreaks, ntemp = vis_lbsize; | |
138 | - | |
139 | - visible_line = invisible_line; | |
140 | - invisible_line = vtemp; | |
141 | - | |
142 | - vis_lbreaks = inv_lbreaks; | |
143 | - inv_lbreaks = itemp; | |
144 | - | |
145 | - vis_lbsize = inv_lbsize; | |
146 | - inv_lbsize = ntemp; | |
147 | + struct line_state *line_state_temp = line_state_visible; | |
148 | + | |
149 | + line_state_visible = line_state_invisible; | |
150 | + line_state_invisible = line_state_temp; | |
151 | ||
152 | rl_display_fixed = 0; | |
153 | /* If we are displaying on a single line, and last_lmargin is > 0, we | |
154 | @@ -1194,8 +1212,9 @@ update_line (old, new, current_line, oma | |
155 | /* This fixes only double-column characters, but if the wrapped | |
156 | character comsumes more than three columns, spaces will be | |
157 | inserted in the string buffer. */ | |
158 | - if (_rl_wrapped_line[current_line] > 0) | |
159 | - _rl_clear_to_eol (_rl_wrapped_line[current_line]); | |
160 | + if (current_line < line_state_visible->wrapped_line_size | |
161 | + && line_state_visible->wrapped_line[current_line] > 0) | |
162 | + _rl_clear_to_eol (line_state_visible->wrapped_line[current_line]); | |
163 | ||
164 | memset (&ps, 0, sizeof (mbstate_t)); | |
165 | ret = mbrtowc (&wc, new, MB_CUR_MAX, &ps); |