Original suggested patch from Marc-Andre Lureau <marcandre.lureau@gmail.com>
Explicitly cast to unsigned char before we do comparisons.
(cherry picked from commit
1f6ac4deef91df3130c61525a2800e6b8a0ddcbf)
len = _dbus_string_get_length (str);
for (i = 0; i < len; i++)
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 = '?';
+ }