From 1f6ac4deef91df3130c61525a2800e6b8a0ddcbf Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Fri, 10 Jul 2009 19:26:52 -0400 Subject: Bug 21646 - Fix a signed char comparison Original suggested patch from Marc-Andre Lureau Explicitly cast to unsigned char before we do comparisons. --- dbus/dbus-sysdeps-util-unix.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'dbus') diff --git a/dbus/dbus-sysdeps-util-unix.c b/dbus/dbus-sysdeps-util-unix.c index f1e20334..07efdfe0 100644 --- a/dbus/dbus-sysdeps-util-unix.c +++ b/dbus/dbus-sysdeps-util-unix.c @@ -1149,10 +1149,13 @@ string_squash_nonprintable (DBusString *str) len = _dbus_string_get_length (str); for (i = 0; i < len; i++) - if (buf[i] == '\0') - buf[i] = ' '; - else if (buf[i] < 0x20 || buf[i] > 127) - buf[i] = '?'; + { + unsigned char c = (unsigned char) buf[i]; + if (c == '\0') + c = ' '; + else if (c < 0x20 || c > 127) + c = '?'; + } } /** -- cgit