/pidgin/main: e7949b2aa31a: Gadu-Gadu: fix log printing for win32

Tomasz Wasilczyk <[email protected]>
Newsgroups gmane.comp.gnome.gaim.cvs
Message-ID <[email protected]>
Changeset: e7949b2aa31ae0f3a49053b31ed715d593b33366
Author:	 Tomasz Wasilczyk <[email protected]>
Date:	 2014-11-24 16:12 +0100
Branch:	 release-2.x.y
URL: https://hg.pidgin.im/pidgin/main/rev/e7949b2aa31a

Description:

Gadu-Gadu: fix log printing for win32

diffstat:

 libpurple/protocols/gg/gg.c |  18 ++++++++++++------
 1 files changed, 12 insertions(+), 6 deletions(-)

diffs (38 lines):

diff --git a/libpurple/protocols/gg/gg.c b/libpurple/protocols/gg/gg.c
--- a/libpurple/protocols/gg/gg.c
+++ b/libpurple/protocols/gg/gg.c
@@ -2365,13 +2365,20 @@ static PurplePluginInfo info = {
 	NULL
 };
 
-static void purple_gg_debug_handler(int level, const char * format, va_list args) {
+static void
+purple_gg_debug_handler(int level, const char * format, va_list args)
+{
 	PurpleDebugLevel purple_level;
-	char *msg = g_strdup_vprintf(format, args);
+	char msgbuff[1000];
+	int ret;
 
-	if (!msg) {
+	/* Don't use glib's printf family, since it might not support
+	 * system-specific formatting modifiers (like %Iu for size on win32). */
+	ret = vsnprintf(msgbuff, sizeof(msgbuff) / sizeof(char), format, args);
+
+	if (ret <= 0) {
 		purple_debug_fatal("gg",
-			"failed to vprintf the following message: %s",
+			"failed to printf the following message: %s",
 			format ? format : "(null)\n");
 
 		return;
@@ -2392,8 +2399,7 @@ static void purple_gg_debug_handler(int 
 			break;
 	}
 
-	purple_debug(purple_level, "gg", "%s", msg);
-	g_free(msg);
+	purple_debug(purple_level, "gg", "%s", msgbuff);
 }
 
 static void init_plugin(PurplePlugin *plugin)
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.