summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog2
-rw-r--r--src/core/wee-string.c7
2 files changed, 9 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 10b859aed..0da74bb3f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -13,6 +13,8 @@ http://weechat.org/files/releasenotes/ReleaseNotes-devel.html[release notes]
== Version 0.4.4 (under dev)
+* core: fix memory leak and use of invalid pointer in split of string (in case
+ of insufficient memory)
* core: fix potential NULL pointer in function gui_color_emphasize
* core: use same return code and message in all commands when arguments are
wrong/missing
diff --git a/src/core/wee-string.c b/src/core/wee-string.c
index 08fb4c7e1..04bd4cb1a 100644
--- a/src/core/wee-string.c
+++ b/src/core/wee-string.c
@@ -1467,7 +1467,14 @@ string_split_internal (const char *string, const char *separators, int keep_eol,
array = malloc ((n_items + 1) * sizeof (array[0]));
if (!array)
+ {
+ free (string2);
return NULL;
+ }
+ for (i = 0; i < n_items + 1; i++)
+ {
+ array[i] = NULL;
+ }
ptr1 = string2;