mirror of
https://github.com/weechat/weechat.git
synced 2026-06-27 21:36:37 +02:00
core: fix bugs with calls to realloc
This commit is contained in:
@@ -1888,23 +1888,28 @@ irc_server_msgq_add_msg (struct t_irc_server *server, const char *msg)
|
||||
void
|
||||
irc_server_msgq_add_unterminated (struct t_irc_server *server, const char *string)
|
||||
{
|
||||
char *unterminated_message2;
|
||||
|
||||
if (!string[0])
|
||||
return;
|
||||
|
||||
if (server->unterminated_message)
|
||||
{
|
||||
server->unterminated_message =
|
||||
unterminated_message2 =
|
||||
realloc (server->unterminated_message,
|
||||
(strlen (server->unterminated_message) +
|
||||
strlen (string) + 1));
|
||||
if (!server->unterminated_message)
|
||||
if (!unterminated_message2)
|
||||
{
|
||||
weechat_printf (server->buffer,
|
||||
_("%s%s: not enough memory for received message"),
|
||||
weechat_prefix ("error"), IRC_PLUGIN_NAME);
|
||||
free (server->unterminated_message);
|
||||
server->unterminated_message = NULL;
|
||||
return;
|
||||
}
|
||||
else
|
||||
strcat (server->unterminated_message, string);
|
||||
server->unterminated_message = unterminated_message2;
|
||||
strcat (server->unterminated_message, string);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user