summaryrefslogtreecommitdiff
path: root/src/plugins/xfer/xfer-chat.c
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2011-08-26 09:55:55 +0200
committerSebastien Helleu <flashcode@flashtux.org>2011-08-26 09:55:55 +0200
commitebf72c7eda87e70aed16e890581307f527567bed (patch)
treefa0b2af5ed236bd33afdbe53ebb4efcfc447a590 /src/plugins/xfer/xfer-chat.c
parentc356b16322fc6d70d8e002796984e57dc5a20d8e (diff)
downloadweechat-ebf72c7eda87e70aed16e890581307f527567bed.zip
core: use dynamic buffer size for calls to vsnprintf
Diffstat (limited to 'src/plugins/xfer/xfer-chat.c')
-rw-r--r--src/plugins/xfer/xfer-chat.c16
1 files changed, 6 insertions, 10 deletions
diff --git a/src/plugins/xfer/xfer-chat.c b/src/plugins/xfer/xfer-chat.c
index 44c406595..baf2acdb9 100644
--- a/src/plugins/xfer/xfer-chat.c
+++ b/src/plugins/xfer/xfer-chat.c
@@ -54,27 +54,21 @@ xfer_chat_send (struct t_xfer *xfer, const char *buffer, int size_buf)
void
xfer_chat_sendf (struct t_xfer *xfer, const char *format, ...)
{
- va_list args;
- static char buffer[4096];
- int size_buf;
char *ptr_msg, *msg_encoded;
if (!xfer || (xfer->sock < 0))
return;
- va_start (args, format);
- size_buf = vsnprintf (buffer, sizeof (buffer) - 1, format, args);
- va_end (args);
- if (size_buf == 0)
+ weechat_va_format (format);
+ if (!vbuffer)
return;
- buffer[sizeof (buffer) - 1] = '\0';
msg_encoded = (xfer->charset_modifier) ?
weechat_hook_modifier_exec ("charset_encode",
xfer->charset_modifier,
- buffer) : NULL;
+ vbuffer) : NULL;
- ptr_msg = (msg_encoded) ? msg_encoded : buffer;
+ ptr_msg = (msg_encoded) ? msg_encoded : vbuffer;
if (xfer_chat_send (xfer, ptr_msg, strlen (ptr_msg)) <= 0)
{
@@ -87,6 +81,8 @@ xfer_chat_sendf (struct t_xfer *xfer, const char *format, ...)
if (msg_encoded)
free (msg_encoded);
+
+ free (vbuffer);
}
/*