fix crash with null arithmetic for expression; fix size_t issue with history search string allocation

This commit is contained in:
Chet Ramey
2023-03-02 12:04:03 -05:00
parent 349e21043e
commit 0bd0fb5966
5 changed files with 54 additions and 7 deletions
+13 -1
View File
@@ -1093,6 +1093,8 @@ rl_redisplay (void)
wc_width = (temp >= 0) ? temp : 1;
}
}
else
wc_width = 1; /* make sure it's set for the META_CHAR check */
#endif
if (in == rl_point)
@@ -1102,12 +1104,22 @@ rl_redisplay (void)
}
#if defined (HANDLE_MULTIBYTE)
if (META_CHAR (c) && _rl_output_meta_chars == 0) /* XXX - clean up */
if (META_CHAR (c) && wc_bytes == 1 && wc_width == 1)
#else
if (META_CHAR (c))
#endif
{
#if 0
/* TAG: readline-8.3 20230227 */
/* https://savannah.gnu.org/support/index.php?110830
asking for non-printing meta characters to be printed using an
escape sequence. */
/* isprint(c) handles bytes up to UCHAR_MAX */
if (_rl_output_meta_chars == 0 || isprint (c) == 0)
#else
if (_rl_output_meta_chars == 0)
#endif
{
char obuf[5];
int olen;
+1 -1
View File
@@ -621,7 +621,7 @@ rl_history_search_reinit (int flags)
if (rl_point)
{
/* Allocate enough space for anchored and non-anchored searches */
if (_rl_history_search_len >= history_string_size - 2)
if (_rl_history_search_len + 2 >= history_string_size)
{
history_string_size = _rl_history_search_len + 2;
history_search_string = (char *)xrealloc (history_search_string, history_string_size);