[PATCH] fix for ppc (and other big-endian cpu's)
Zaheer Abbas Merali
zaheerabbas@merali.org
Sat, 31 Jan 2004 20:26:23 +0000
--=-Gvn0HPBIgq8ZYNLNW5Fr
Content-Type: text/plain
Content-Transfer-Encoding: 7bit
Hi guys
I have attached a patch that will stop dbus segfaulting on ppc's. It
segfaults due to a va_list being used more than once. If it is to be
used more than once, it needs to be copied using va_copy.
--
Zaheer Abbas Merali <zaheerabbas@merali.org>
--=-Gvn0HPBIgq8ZYNLNW5Fr
Content-Disposition: attachment; filename=dbus-string-varargs.diff
Content-Type: text/x-patch; name=dbus-string-varargs.diff; charset=us-ascii
Content-Transfer-Encoding: 7bit
Index: dbus-string.c
===================================================================
RCS file: /cvs/dbus/dbus/dbus/dbus-string.c,v
retrieving revision 1.45
diff -u -r1.45 dbus-string.c
--- dbus-string.c 2 Dec 2003 10:44:21 -0000 1.45
+++ dbus-string.c 31 Jan 2004 19:44:26 -0000
@@ -1013,17 +1013,21 @@
{
int len;
char c;
+ va_list tmp,tmp2;
DBUS_STRING_PREAMBLE (str);
+ va_copy(tmp,args);
+ va_copy(tmp2,args);
/* Measure the message length without terminating nul */
- len = vsnprintf (&c, 1, format, args);
-
+ len = vsnprintf (&c, 1, format, tmp);
+ va_end(tmp);
if (!_dbus_string_lengthen (str, len))
return FALSE;
- vsprintf (real->str + (real->len - len),
- format, args);
+ vsprintf (real->str + (real->len - len),
+ format, tmp2);
+ va_end(tmp2);
return TRUE;
}
--=-Gvn0HPBIgq8ZYNLNW5Fr--