[patch] varargs use
David Zeuthen
david@fubar.dk
Sat, 20 Dec 2003 18:56:33 +0100
Hi,
D-BUS from CVS (and version 0.20 also), segfaults when starting on a
powerpc system running debian testing/unstable. This patch fixes a
vararg bug which resolves the segfaults.
Okay to commit?
Thanks,
David
Index: ChangeLog
===================================================================
RCS file: /cvs/dbus/dbus/ChangeLog,v
retrieving revision 1.448
diff -u -p -r1.448 ChangeLog
--- ChangeLog 17 Dec 2003 12:24:33 -0000 1.448
+++ ChangeLog 20 Dec 2003 17:53:35 -0000
@@ -1,3 +1,9 @@
+2003-12-20 David Zeuthen <david@fubar.dk>
+
+ * dbus/dbus-string.c (_dbus_string_append_printf_valist): Fix a
+ bug where args were used twice. This bug resulted in a segfault
+ on a Debian/PPC system when starting the messagebus daemon.
+
2003-12-17 Mikael Hallendal <micke@imendio.com>
* dbus/dbus-message.c: (dbus_message_append_args_valist):
Index: dbus/dbus-string.c
===================================================================
RCS file: /cvs/dbus/dbus/dbus/dbus-string.c,v
retrieving revision 1.45
diff -u -p -r1.45 dbus-string.c
--- dbus/dbus-string.c 2 Dec 2003 10:44:21 -0000 1.45
+++ dbus/dbus-string.c 20 Dec 2003 17:53:37 -0000
@@ -1013,16 +1013,22 @@ _dbus_string_append_printf_valist (DBus
{
int len;
char c;
+ va_list args_copy;
+
DBUS_STRING_PREAMBLE (str);
-
+
+ va_copy(args_copy, args);
+
/* Measure the message length without terminating nul */
len = vsnprintf (&c, 1, format, args);
if (!_dbus_string_lengthen (str, len))
return FALSE;
-
+
vsprintf (real->str + (real->len - len),
- format, args);
+ format, args_copy);
+
+ va_end(args_copy);
return TRUE;
}