1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-25 20:36: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
+8 -3
View File
@@ -130,7 +130,7 @@ char *
rmodifier_replace_groups (const char *string, regmatch_t regex_match[],
const char *groups)
{
char *result, *str_group, *string_to_add;
char *result, *result2, *str_group, *string_to_add;
const char *ptr_groups;
int length, num_group;
@@ -161,9 +161,14 @@ rmodifier_replace_groups (const char *string, regmatch_t regex_match[],
if (string_to_add)
{
length += strlen (string_to_add);
result = realloc (result, length);
if (!result)
result2 = realloc (result, length);
if (!result2)
{
if (result)
free (result);
return NULL;
}
result = result2;
strcat (result, string_to_add);
free (string_to_add);
}