summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2021-11-20 13:19:44 +0100
committerSébastien Helleu <flashcode@flashtux.org>2021-11-20 13:21:51 +0100
commit006964c4dc2fe26c5a16a3f7b5785fde926ff4ce (patch)
tree67aa4e1f2fe379731c7ac749baf31b64461e120d /src
parent05d31b476bd2e17577278c420dce08cd935927b9 (diff)
downloadweechat-006964c4dc2fe26c5a16a3f7b5785fde926ff4ce.zip
irc: fix memory leak in case of realloc error
Diffstat (limited to 'src')
-rw-r--r--src/plugins/irc/irc-message.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/plugins/irc/irc-message.c b/src/plugins/irc/irc-message.c
index ceca9707f..e5beb2f88 100644
--- a/src/plugins/irc/irc-message.c
+++ b/src/plugins/irc/irc-message.c
@@ -60,6 +60,7 @@ irc_message_parse_params (const char *parameters,
char ***params, int *num_params)
{
const char *ptr_params, *pos_end, *pos_next;
+ char **new_params;
int alloc_params, trailing;
if (!params && !num_params)
@@ -113,10 +114,11 @@ irc_message_parse_params (const char *parameters,
if (params)
{
alloc_params++;
- *params = realloc (*params,
- (alloc_params + 1) * sizeof ((*params)[0]));
- if (!*params)
+ new_params = realloc (*params,
+ (alloc_params + 1) * sizeof ((*params)[0]));
+ if (!new_params)
return;
+ *params = new_params;
(*params)[alloc_params - 1] = weechat_strndup (ptr_params,
pos_end - ptr_params);
(*params)[alloc_params] = NULL;