1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-27 05:16:38 +02:00

core: fix bugs with calls to realloc

This commit is contained in:
Sebastien Helleu
2011-08-28 15:25:30 +02:00
parent e411d14b7a
commit f843f904bc
16 changed files with 259 additions and 106 deletions
+6 -3
View File
@@ -607,7 +607,7 @@ gui_buffer_string_replace_local_var (struct t_gui_buffer *buffer,
const char *string)
{
int length, length_var, index_string, index_result;
char *result, *local_var;
char *result, *result2, *local_var;
const char *pos_end_name, *ptr_value;
if (!string)
@@ -646,12 +646,15 @@ gui_buffer_string_replace_local_var (struct t_gui_buffer *buffer,
{
length_var = strlen (ptr_value);
length += length_var;
result = realloc (result, length);
if (!result)
result2 = realloc (result, length);
if (!result2)
{
if (result)
free (result);
free (local_var);
return NULL;
}
result = result2;
strcpy (result + index_result, ptr_value);
index_result += length_var;
index_string += strlen (local_var) + 1;