diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2011-08-28 15:25:30 +0200 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2011-08-28 15:25:30 +0200 |
commit | f843f904bc9fc1c8d0d2dfddd5e15aaa9738ec0d (patch) | |
tree | 82944d494970ee9095e0dfd59cb2edaf067cb379 /src/plugins/alias/alias.c | |
parent | e411d14b7a239b47a87f22c20ce193e37481f672 (diff) | |
download | weechat-f843f904bc9fc1c8d0d2dfddd5e15aaa9738ec0d.zip |
core: fix bugs with calls to realloc
Diffstat (limited to 'src/plugins/alias/alias.c')
-rw-r--r-- | src/plugins/alias/alias.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/plugins/alias/alias.c b/src/plugins/alias/alias.c index e1172235a..969745d8d 100644 --- a/src/plugins/alias/alias.c +++ b/src/plugins/alias/alias.c @@ -97,7 +97,8 @@ void alias_string_add_word (char **alias, int *length, const char *word) { int length_word; - + char *alias2; + if (!word) return; @@ -112,7 +113,17 @@ alias_string_add_word (char **alias, int *length, const char *word) } else { - *alias = realloc (*alias, strlen (*alias) + length_word + 1); + alias2 = realloc (*alias, strlen (*alias) + length_word + 1); + if (!alias2) + { + if (*alias) + { + free (*alias); + *alias = NULL; + } + return; + } + *alias = alias2; strcat (*alias, word); } *length += length_word; |