summaryrefslogtreecommitdiffstats
path: root/dbus/dbus-string.c
diff options
context:
space:
mode:
authorHavoc Pennington <hp@redhat.com>2003-03-16 20:16:47 +0000
committerHavoc Pennington <hp@redhat.com>2003-03-16 20:16:47 +0000
commitebb57e719c32becd95a1efe3dd269c21e5a011b6 (patch)
tree1712e557855a60576828b45683505d329631a462 /dbus/dbus-string.c
parent021305e5686fc4847fec942922d2115ae5c9c2bb (diff)
2003-03-16 Havoc Pennington <hp@pobox.com>
* dbus/dbus-string.c (_dbus_string_validate_utf8): oops, unbreak this. always run the test suite before commit... * bus/*: adapt to DBusConnection API changes * glib/dbus-gmain.c: adapt to DBusConnection API changes, requires renaming stuff to avoid dbus_connection_dispatch name conflict. * dbus/dbus-transport.c (_dbus_transport_queue_messages): new function * dbus/dbus-message.c (_dbus_message_loader_queue_messages): separate from _dbus_message_loader_return_buffer() * dbus/dbus-connection.c (dbus_connection_get_n_messages): remove this, because it's now always broken to use; the number of messages in queue vs. the number still buffered by the message loader is undefined/meaningless. Should use dbus_connection_get_dispatch_state(). (dbus_connection_dispatch): rename from dbus_connection_dispatch_message
Diffstat (limited to 'dbus/dbus-string.c')
-rw-r--r--dbus/dbus-string.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/dbus/dbus-string.c b/dbus/dbus-string.c
index 1a50dac7..1bc3e205 100644
--- a/dbus/dbus-string.c
+++ b/dbus/dbus-string.c
@@ -2395,6 +2395,7 @@ _dbus_string_validate_utf8 (const DBusString *str,
int len)
{
const unsigned char *p;
+ const unsigned char *end;
DBUS_CONST_STRING_PREAMBLE (str);
_dbus_assert (start >= 0);
_dbus_assert (start <= real->len);
@@ -2403,9 +2404,10 @@ _dbus_string_validate_utf8 (const DBusString *str,
if (len > real->len - start)
return FALSE;
- p = real->str;
+ p = real->str + start;
+ end = p + len;
- while (p - real->str < len && *p)
+ while (p < end)
{
int i, mask = 0, char_len;
dbus_unichar_t result;
@@ -2416,20 +2418,20 @@ _dbus_string_validate_utf8 (const DBusString *str,
if (char_len == -1)
break;
- /* check that the expected number of bytes exists in real->str */
- if ((len - (p - real->str)) < char_len)
+ /* check that the expected number of bytes exists in the remaining length */
+ if ((end - p) < char_len)
break;
UTF8_GET (result, p, i, mask, char_len);
if (UTF8_LENGTH (result) != char_len) /* Check for overlong UTF-8 */
- break;
+ break;
if (result == (dbus_unichar_t)-1)
break;
if (!UNICODE_VALID (result))
- break;
+ break;
p += char_len;
}
@@ -2437,7 +2439,7 @@ _dbus_string_validate_utf8 (const DBusString *str,
/* See that we covered the entire length if a length was
* passed in
*/
- if (p != (real->str + len))
+ if (p != end)
return FALSE;
else
return TRUE;