api: fix memory leak in function string_split

v2.8-utf8proc
Sébastien Helleu 2018-08-15 09:42:43 +02:00
parent aff752c50b
commit 6d061a9ac0
2 changed files with 7 additions and 1 deletions

View File

@ -28,6 +28,7 @@ Bug fixes::
* core: fix check of tags in lines (command /filter and hook_print)
* core: fix clear of completion item in case of partial completion (issue #1162)
* core: send signal "key_pressed" for mouse code only if the string is UTF-8 valid (issue #1220)
* api: fix memory leak in function string_split
* scripts: fix duplicated lines in output of script eval (python, perl, ruby, lua and guile)
[[v2.2]]

View File

@ -1752,8 +1752,13 @@ string_split_internal (const char *string, const char *separators, int keep_eol,
return NULL;
string2 = string_strip (string, 1, (keep_eol == 2) ? 0 : 1, separators);
if (!string2 || !string2[0])
if (!string2)
return NULL;
if (!string2[0])
{
free (string2);
return NULL;
}
/* calculate number of items */
ptr = string2;