changeset 13926:756c3d7177d9

[gaim-migrate @ 16445] Fix a crash bug on some systems (mostly amd64) caused by using a va_list twice. My bad! Thanks to Kevin Stange and Vincent Ho for noticing this and suggesting the cause. Vincent's IRC handle reminds me of a Harvey Danger song. committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Thu, 06 Jul 2006 09:21:57 +0000
parents 60f39c405dff
children 9309d27d780c
files src/debug.c src/debug.h src/gtkdebug.c
diffstat 3 files changed, 15 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/src/debug.c	Thu Jul 06 08:24:26 2006 +0000
+++ b/src/debug.c	Thu Jul 06 09:21:57 2006 +0000
@@ -46,14 +46,20 @@
 				 const char *format, va_list args)
 {
 	GaimDebugUiOps *ops;
+	char *arg_s = NULL;
 
 	g_return_if_fail(level != GAIM_DEBUG_ALL);
 	g_return_if_fail(format != NULL);
 
+	ops = gaim_debug_get_ui_ops();
+
+	if (!debug_enabled && ((ops == NULL) || (ops->print == NULL)))
+		return;
+
+	arg_s = g_strdup_vprintf(format, args);
+
 	if (debug_enabled) {
-		gchar *arg_s, *ts_s;
-
-		arg_s = g_strdup_vprintf(format, args);
+		gchar *ts_s;
 
 		if ((category != NULL) &&
 			(gaim_prefs_exists("/core/debug/timestamps")) &&
@@ -72,14 +78,13 @@
 		else
 			g_print("%s%s: %s", ts_s, category, arg_s);
 
-		g_free(arg_s);
 		g_free(ts_s);
 	}
 
-	ops = gaim_debug_get_ui_ops();
+	if (ops != NULL && ops->print != NULL)
+		ops->print(level, category, arg_s);
 
-	if (ops != NULL && ops->print != NULL)
-		ops->print(level, category, format, args);
+	g_free(arg_s);
 }
 
 void
--- a/src/debug.h	Thu Jul 06 08:24:26 2006 +0000
+++ b/src/debug.h	Thu Jul 06 09:21:57 2006 +0000
@@ -48,7 +48,7 @@
 typedef struct
 {
 	void (*print)(GaimDebugLevel level, const char *category,
-				  const char *format, va_list args);
+				  const char *arg_s);
 } GaimDebugUiOps;
 
 #ifdef __cplusplus
--- a/src/gtkdebug.c	Thu Jul 06 08:24:26 2006 +0000
+++ b/src/gtkdebug.c	Thu Jul 06 09:21:57 2006 +0000
@@ -931,13 +931,13 @@
 
 static void
 gaim_gtk_debug_print(GaimDebugLevel level, const char *category,
-					 const char *format, va_list args)
+					 const char *arg_s)
 {
 #ifdef HAVE_REGEX_H
 	GtkTreeIter iter;
 #endif /* HAVE_REGEX_H */
 	gboolean timestamps;
-	gchar *arg_s, *ts_s;
+	gchar *ts_s;
 	gchar *esc_s, *cat_s, *tmp, *s;
 
 	if (!gaim_prefs_get_bool("/gaim/gtk/debug/enabled") ||
@@ -948,8 +948,6 @@
 
 	timestamps = gaim_prefs_get_bool("/core/debug/timestamps");
 
-	arg_s = g_strdup_vprintf(format, args);
-
 	/*
 	 * For some reason we only print the timestamp if category is
 	 * not NULL.  Why the hell do we do that?  --Mark
@@ -971,8 +969,6 @@
 
 	esc_s = g_markup_escape_text(arg_s, -1);
 
-	g_free(arg_s);
-
 	s = g_strdup_printf("<font color=\"%s\">%s%s%s</font>",
 						debug_fg_colors[level], ts_s, cat_s, esc_s);