1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-06 09:43:13 +02:00

api: do not free dynamic string on error in function string_dyn_concat

This commit is contained in:
Sébastien Helleu
2026-07-05 11:59:18 +02:00
parent 20f5ecc6dd
commit f65591cb56
7 changed files with 16 additions and 4 deletions
+2 -4
View File
@@ -4763,6 +4763,8 @@ string_dyn_copy (char **string, const char *new_string)
* if the string had to be extended, or the same pointer if there was enough
* size to concatenate the new string.
*
* In case of error, the dynamic string is left unchanged.
*
* Return:
* 1: OK
* 0: error
@@ -4798,11 +4800,7 @@ string_dyn_concat (char **string, const char *add, int bytes)
new_size_alloc = new_size;
string_realloc = realloc (ptr_string_dyn->string, new_size_alloc);
if (!string_realloc)
{
free (ptr_string_dyn->string);
free (ptr_string_dyn);
return 0;
}
ptr_string_dyn->string = string_realloc;
ptr_string_dyn->size_alloc = new_size_alloc;
}