mirror of
https://github.com/weechat/weechat.git
synced 2026-06-12 14:14:48 +02:00
api: fix infinite loop in function string_replace when the search string is empty
This commit is contained in:
@@ -20,6 +20,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
|||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
- core: fix option weechat.look.color_real_white not applied when color is "white" on 16+ colors terminals ([#1742](https://github.com/weechat/weechat/issues/1742))
|
- core: fix option weechat.look.color_real_white not applied when color is "white" on 16+ colors terminals ([#1742](https://github.com/weechat/weechat/issues/1742))
|
||||||
|
- api: fix infinite loop in function string_replace when the search string is empty
|
||||||
- irc: fix tag in message with list of names when joining a channel
|
- irc: fix tag in message with list of names when joining a channel
|
||||||
- fset: remove error displayed in core buffer when clicking with the mouse below the last option displayed
|
- fset: remove error displayed in core buffer when clicking with the mouse below the last option displayed
|
||||||
- irc: limit size of data received from the server to prevent memory exhaustion
|
- irc: limit size of data received from the server to prevent memory exhaustion
|
||||||
|
|||||||
@@ -1966,6 +1966,9 @@ string_replace (const char *string, const char *search, const char *replace)
|
|||||||
if (!string || !search || !replace)
|
if (!string || !search || !replace)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
if (!search[0])
|
||||||
|
return strdup (string);
|
||||||
|
|
||||||
length1 = strlen (search);
|
length1 = strlen (search);
|
||||||
length2 = strlen (replace);
|
length2 = strlen (replace);
|
||||||
|
|
||||||
|
|||||||
@@ -1454,6 +1454,8 @@ TEST(CoreString, Replace)
|
|||||||
WEE_TEST_STR(NULL, string_replace ("string", NULL, "replace"));
|
WEE_TEST_STR(NULL, string_replace ("string", NULL, "replace"));
|
||||||
WEE_TEST_STR(NULL, string_replace (NULL, "search", "replace"));
|
WEE_TEST_STR(NULL, string_replace (NULL, "search", "replace"));
|
||||||
|
|
||||||
|
WEE_TEST_STR("test abc def", string_replace("test abc def", "", "xxx"));
|
||||||
|
|
||||||
WEE_TEST_STR("test abc def", string_replace("test abc def", "xyz", "xxx"));
|
WEE_TEST_STR("test abc def", string_replace("test abc def", "xyz", "xxx"));
|
||||||
WEE_TEST_STR("test xxx def", string_replace("test abc def", "abc", "xxx"));
|
WEE_TEST_STR("test xxx def", string_replace("test abc def", "abc", "xxx"));
|
||||||
WEE_TEST_STR("xxx test xxx def xxx",
|
WEE_TEST_STR("xxx test xxx def xxx",
|
||||||
|
|||||||
Reference in New Issue
Block a user