From 03d36f13af4cd1abf855e902f8435a1aa7e4d30b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Helleu?= Date: Fri, 13 Nov 2020 21:26:16 +0100 Subject: [PATCH] spell: fix refresh of bar item "spell_suggest" when the input becomes empty (issue #1586) When the input is empty, length of string is zero: when sending zero to function weechat_string_dyn_alloc, the function returns NULL and therefore we return immediately instead of handling the empty input, which is a valid value. The regression was introduced by the use of dynamic strings, commit: 299f74bfef9e0d239ad141a4df3b2dcf11a4c0da (cherry picked from commit eb90a73fe811e2de0e0646abf10242e639a7b1a1) --- ChangeLog.adoc | 1 + src/plugins/spell/spell.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/ChangeLog.adoc b/ChangeLog.adoc index e91bd2ab2..cfa59545a 100644 --- a/ChangeLog.adoc +++ b/ChangeLog.adoc @@ -20,6 +20,7 @@ https://weechat.org/files/releasenotes/ReleaseNotes-devel.html[release notes] Bug fixes:: + * spell: fix refresh of bar item "spell_suggest" when the input becomes empty (issue #1586) * spell: fix crash with IRC color codes in command line (issue #1589) [[v3.0]] diff --git a/src/plugins/spell/spell.c b/src/plugins/spell/spell.c index 4ecd3a433..868e3f12c 100644 --- a/src/plugins/spell/spell.c +++ b/src/plugins/spell/spell.c @@ -802,7 +802,7 @@ spell_modifier_cb (const void *pointer, void *data, color_error = weechat_color (weechat_config_string (spell_config_color_misspelled)); length = strlen (string); - result = weechat_string_dyn_alloc (length * 2); + result = weechat_string_dyn_alloc ((length * 2) + 1); if (!result) return NULL;