diff --git a/ChangeLog.asciidoc b/ChangeLog.asciidoc index 3e104ee96..53ab7cc43 100644 --- a/ChangeLog.asciidoc +++ b/ChangeLog.asciidoc @@ -15,6 +15,8 @@ http://weechat.org/files/releasenotes/ReleaseNotes-devel.html[release notes] == Version 0.4.4 (under dev) +* core: fix add of filter on OS X when regex for message is empty (filter regex + ending with "\t") * core: check validity of buffer pointer when data is sent to a buffer (command/text from user and API function "command") * core: fix crash when buffer is closed during execution of multiple commands diff --git a/src/gui/gui-filter.c b/src/gui/gui-filter.c index dc2342efe..8e57e58d9 100644 --- a/src/gui/gui-filter.c +++ b/src/gui/gui-filter.c @@ -284,6 +284,7 @@ gui_filter_new (int enabled, const char *name, const char *buffer_name, regex1 = NULL; regex2 = NULL; + if (strcmp (ptr_start_regex, "*") != 0) { pos_tab = strstr (ptr_start_regex, "\\t"); @@ -299,7 +300,7 @@ gui_filter_new (int enabled, const char *name, const char *buffer_name, pos_regex_message = ptr_start_regex; } - if (regex_prefix) + if (regex_prefix && regex_prefix[0]) { regex1 = malloc (sizeof (*regex1)); if (regex1) @@ -314,18 +315,24 @@ gui_filter_new (int enabled, const char *name, const char *buffer_name, } } - regex2 = malloc (sizeof (*regex2)); - if (regex2) + if (pos_regex_message && pos_regex_message[0]) { - if (string_regcomp (regex2, pos_regex_message, - REG_EXTENDED | REG_ICASE | REG_NOSUB) != 0) + regex2 = malloc (sizeof (*regex2)); + if (regex2) { - if (regex_prefix) - free (regex_prefix); - if (regex1) - free (regex1); - free (regex2); - return NULL; + if (string_regcomp (regex2, pos_regex_message, + REG_EXTENDED | REG_ICASE | REG_NOSUB) != 0) + { + if (regex_prefix) + free (regex_prefix); + if (regex1) + { + regfree (regex1); + free (regex1); + } + free (regex2); + return NULL; + } } }