mirror of
https://github.com/weechat/weechat.git
synced 2026-06-27 21:36:37 +02:00
core: fix buffer overflow in function utf8_next_char and return NULL for empty string
Now the function utf8_next_char with an empty string returns NULL instead of
the next char, which is most of the time after an allocated buffer.
And the function utf8_char_size with an empty string now returns 0 instead of
1.
This indirectly fixes a buffer overflow in function eval_string_range_chars
when the input string is empty (for example when doing `/eval -n ${chars:}`).
This commit is contained in:
@@ -1079,12 +1079,12 @@ irc_message_split_string (struct t_irc_message_split_context *context,
|
||||
pos = arguments;
|
||||
pos_max = pos + max_length;
|
||||
pos_last_delim = NULL;
|
||||
while (pos[0])
|
||||
while (pos && pos[0])
|
||||
{
|
||||
if (pos[0] == delimiter)
|
||||
pos_last_delim = pos;
|
||||
pos_next = weechat_utf8_next_char (pos);
|
||||
if (pos_next > pos_max)
|
||||
if (!pos_next || (pos_next > pos_max))
|
||||
break;
|
||||
pos = pos_next;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user