summaryrefslogtreecommitdiffstats
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
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.
-rw-r--r--ChangeLog9
-rw-r--r--dbus/dbus-marshal.c27
-rw-r--r--dbus/dbus-message.c25
3 files changed, 48 insertions, 13 deletions
diff --git a/ChangeLog b/ChangeLog
index 976e0d47..a73d3f31 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
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.
+
+2003-01-07 Anders Carlsson <andersca@codefactory.se>
+
* dbus/dbus-marshal.c: (_dbus_marshal_string),
(_dbus_demarshal_string), (_dbus_marshal_test):
* dbus/dbus-marshal.h:
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);
}
diff --git a/dbus/dbus-message.c b/dbus/dbus-message.c
index b7f66644..864887ad 100644
--- a/dbus/dbus-message.c
+++ b/dbus/dbus-message.c
@@ -230,7 +230,10 @@ dbus_message_append_int32 (DBusMessage *message,
_dbus_assert (!message->locked);
if (!_dbus_string_append_byte (&message->body, DBUS_TYPE_INT32))
- return FALSE;
+ {
+ _dbus_string_shorten (&message->body, 1);
+ return FALSE;
+ }
return _dbus_marshal_int32 (&message->body,
DBUS_COMPILER_BYTE_ORDER, value);
@@ -251,7 +254,10 @@ dbus_message_append_uint32 (DBusMessage *message,
_dbus_assert (!message->locked);
if (!_dbus_string_append_byte (&message->body, DBUS_TYPE_UINT32))
- return FALSE;
+ {
+ _dbus_string_shorten (&message->body, 1);
+ return FALSE;
+ }
return _dbus_marshal_uint32 (&message->body,
DBUS_COMPILER_BYTE_ORDER, value);
@@ -272,7 +278,10 @@ dbus_message_append_double (DBusMessage *message,
_dbus_assert (!message->locked);
if (!_dbus_string_append_byte (&message->body, DBUS_TYPE_INT32))
- return FALSE;
+ {
+ _dbus_string_shorten (&message->body, 1);
+ return FALSE;
+ }
return _dbus_marshal_double (&message->body,
DBUS_COMPILER_BYTE_ORDER, value);
@@ -294,7 +303,10 @@ dbus_message_append_string (DBusMessage *message,
_dbus_assert (value != NULL);
if (!_dbus_string_append_byte (&message->body, DBUS_TYPE_UTF8_STRING))
- return FALSE;
+ {
+ _dbus_string_shorten (&message->body, 1);
+ return FALSE;
+ }
return _dbus_marshal_string (&message->body,
DBUS_COMPILER_BYTE_ORDER, value);
@@ -318,7 +330,10 @@ dbus_message_append_byte_array (DBusMessage *message,
_dbus_assert (value != NULL);
if (!_dbus_string_append_byte (&message->body, DBUS_TYPE_BYTE_ARRAY))
- return FALSE;
+ {
+ _dbus_string_shorten (&message->body, 1);
+ return FALSE;
+ }
return _dbus_marshal_byte_array (&message->body,
DBUS_COMPILER_BYTE_ORDER, value, len);