From bbe01eff1916434069ec4af4256789e9591687b5 Mon Sep 17 00:00:00 2001 From: Sebastien Helleu Date: Sat, 18 Oct 2008 17:54:33 +0200 Subject: [PATCH] Fix malloc of 0 byte in aspell plugin --- src/plugins/aspell/aspell.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/plugins/aspell/aspell.c b/src/plugins/aspell/aspell.c index b44f78dea..33628f78c 100644 --- a/src/plugins/aspell/aspell.c +++ b/src/plugins/aspell/aspell.c @@ -755,7 +755,7 @@ weechat_aspell_modifier_cb (void *data, const char *modifier, (void) data; (void) modifier; - if (!string) + if (!string || !string[0]) return NULL; sscanf (modifier_data, "%x", &value); @@ -795,11 +795,12 @@ weechat_aspell_modifier_cb (void *data, const char *modifier, length_color_error = strlen (color_error); length = strlen (string); - result = malloc (length + (length * length_color_error)); - result[0] = '\0'; + result = malloc (length + (length * length_color_error) + 1); if (result) { + result[0] = '\0'; + ptr_string = aspell_last_modifier_string; index_result = 0; @@ -881,7 +882,7 @@ weechat_aspell_modifier_cb (void *data, const char *modifier, result[index_result] = '\0'; } - + if (!result) return NULL;