+static void
+randomly_change_one_type (const DBusString *orig_data,
+ DBusString *mutated)
+{
+ int i;
+ int len;
+
+ if (orig_data != mutated)
+ {
+ _dbus_string_set_length (mutated, 0);
+
+ if (!_dbus_string_copy (orig_data, 0, mutated, 0))
+ _dbus_assert_not_reached ("out of mem");
+ }
+
+ if (_dbus_string_get_length (mutated) == 0)
+ return;
+
+ len = _dbus_string_get_length (mutated);
+ i = random_int_in_range (0, len);
+
+ /* Look for a type starting at a random location,
+ * and replace with a different type
+ */
+ while (i < len)
+ {
+ int b;
+ b = _dbus_string_get_byte (mutated, i);
+ if (b > DBUS_TYPE_INVALID && b <= DBUS_TYPE_LAST)
+ {
+ _dbus_string_set_byte (mutated, i,
+ random_int_in_range (DBUS_TYPE_INVALID,
+ DBUS_TYPE_LAST + 1));
+ return;
+ }
+ ++i;
+ }
+}
+