summaryrefslogtreecommitdiffstats
path: root/dbus/dbus-marshal.c
diff options
context:
space:
mode:
authorAnders Carlsson <andersca@codefactory.se>2003-01-06 22:19:09 +0000
committerAnders Carlsson <andersca@codefactory.se>2003-01-06 22:19:09 +0000
commit3d2dee2a7ff006d95a8f1225db80d49883b13a76 (patch)
treeb5e89d474e6e45a0bf10e077abe21d1158632736 /dbus/dbus-marshal.c
parent5175ad00e1d648a89efdf8d397b31bf84fd203c8 (diff)
2003-01-07 Anders Carlsson <andersca@codefactory.se>
* dbus/dbus-marshal.c: (_dbus_marshal_double), (_dbus_marshal_string), (_dbus_marshal_byte_array): * dbus/dbus-message.c: (dbus_message_append_int32), (dbus_message_append_uint32), (dbus_message_append_double), (dbus_message_append_string), (dbus_message_append_byte_array): Handle OOM restoration.
Diffstat (limited to 'dbus/dbus-marshal.c')
-rw-r--r--dbus/dbus-marshal.c27
1 files changed, 19 insertions, 8 deletions
diff --git a/dbus/dbus-marshal.c b/dbus/dbus-marshal.c
index 6e4f4143..8e14d702 100644
--- a/dbus/dbus-marshal.c
+++ b/dbus/dbus-marshal.c
@@ -137,11 +137,6 @@ _dbus_marshal_double (DBusString *str,
int byte_order,
double value)
{
- if (!_dbus_string_set_length (str,
- DBUS_ALIGN_VALUE (_dbus_string_get_length (str),
- sizeof (double))))
- return FALSE;
-
if (byte_order != DBUS_COMPILER_BYTE_ORDER)
swap_bytes ((unsigned char *)&value, sizeof (double));
@@ -209,12 +204,19 @@ _dbus_marshal_string (DBusString *str,
int byte_order,
const char *value)
{
- int len;
+ int len, old_string_len;
+ old_string_len = _dbus_string_get_length (str);
+
len = strlen (value);
if (!_dbus_marshal_uint32 (str, byte_order, len))
- return FALSE;
+ {
+ /* Restore the previous length */
+ _dbus_string_set_length (str, old_string_len);
+
+ return FALSE;
+ }
return _dbus_string_append_len (str, value, len + 1);
}
@@ -234,8 +236,17 @@ _dbus_marshal_byte_array (DBusString *str,
const unsigned char *value,
int len)
{
+ int old_string_len;
+
+ old_string_len = _dbus_string_get_length (str);
+
if (!_dbus_marshal_uint32 (str, byte_order, len))
- return FALSE;
+ {
+ /* Restore the previous length */
+ _dbus_string_set_length (str, old_string_len);
+
+ return FALSE;
+ }
return _dbus_string_append_len (str, value, len);
}