To fix this problem, the problematic code was replaced by a new function
_dbus_string_get_allocated_size(), which uses the existing macro
DBUS_CONST_STRING_PREAMBLE for these purposes.
Signed-off-by: Ralf Habacker <ralf.habacker@freenet.de>
Part-of: https://gitlab.freedesktop.org/dbus/dbus/-/merge_requests/275
Reviewed-by: Simon McVittie <smcv@collabora.com>
return TRUE;
}
+/**
+ * Returns the allocated size of the string
+ *
+ * @param str the string
+ * @returns the allocated size
+ */
+int
+_dbus_string_get_allocated_size (const DBusString *str)
+{
+ DBUS_CONST_STRING_PREAMBLE (str);
+
+ return real->allocated;
+}
+
#ifndef _dbus_string_get_data
/**
* Gets the raw character buffer from the string. The returned buffer
DBUS_PRIVATE_EXPORT
dbus_bool_t _dbus_string_compact (DBusString *str,
int max_waste);
+DBUS_PRIVATE_EXPORT
+int _dbus_string_get_allocated_size (const DBusString *str);
#ifndef _dbus_string_get_data
DBUS_PRIVATE_EXPORT
char* _dbus_string_get_data (DBusString *str);
_dbus_test_fatal ("failed to compact after set_length");
/* peek inside to make sure it worked */
- if (((DBusRealString *)&str)->allocated > 30)
+ if (_dbus_string_get_allocated_size (&str) > 30)
_dbus_test_fatal ("compacting string didn't do anything");
if (!_dbus_string_equal_c_str (&str, "abcdefghij"))