diff options
author | Anders Carlsson <andersca@codefactory.se> | 2003-01-06 22:19:09 +0000 |
---|---|---|
committer | Anders Carlsson <andersca@codefactory.se> | 2003-01-06 22:19:09 +0000 |
commit | 3d2dee2a7ff006d95a8f1225db80d49883b13a76 (patch) | |
tree | b5e89d474e6e45a0bf10e077abe21d1158632736 /dbus/dbus-marshal.c | |
parent | 5175ad00e1d648a89efdf8d397b31bf84fd203c8 (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.c | 27 |
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); } |