X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dbus%2Fdbus-string.c;h=18e87eb248e24851a91cbecdad796c63f8b40642;hb=383f596c4aee2561c90abca3ce9d1f52407a3eec;hp=9accdb198766b112a47ff6fb85582548d766b4c6;hpb=d891d816d74d2d89bd511f68a4b389fda6c161a8;p=platform%2Fupstream%2Fdbus.git diff --git a/dbus/dbus-string.c b/dbus/dbus-string.c index 9accdb1..18e87eb 100644 --- a/dbus/dbus-string.c +++ b/dbus/dbus-string.c @@ -246,6 +246,14 @@ _dbus_string_free (DBusString *str) if (real->constant) return; + + /* so it's safe if @p str returned by a failed + * _dbus_string_init call + * Bug: https://bugs.freedesktop.org/show_bug.cgi?id=65959 + */ + if (real->str == NULL) + return; + dbus_free (real->str - real->align_offset); real->invalid = TRUE; @@ -277,9 +285,9 @@ compact (DBusRealString *real, return TRUE; } -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS /* Not using this feature at the moment, - * so marked DBUS_BUILD_TESTS-only + * so marked DBUS_ENABLE_EMBEDDED_TESTS-only */ /** * Locks a string such that any attempts to change the string will @@ -303,7 +311,7 @@ _dbus_string_lock (DBusString *str) #define MAX_WASTE 48 compact (real, MAX_WASTE); } -#endif /* DBUS_BUILD_TESTS */ +#endif /* DBUS_ENABLE_EMBEDDED_TESTS */ static dbus_bool_t reallocate_for_length (DBusRealString *real, @@ -329,11 +337,11 @@ reallocate_for_length (DBusRealString *real, */ #ifdef DBUS_DISABLE_ASSERT #else -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS new_allocated = 0; /* ensure a realloc every time so that we go * through all malloc failure codepaths */ -#endif /* DBUS_BUILD_TESTS */ +#endif /* DBUS_ENABLE_EMBEDDED_TESTS */ #endif /* !DBUS_DISABLE_ASSERT */ /* But be sure we always alloc at least space for the new length */ @@ -969,7 +977,7 @@ do { \ dbus_bool_t _dbus_string_insert_2_aligned (DBusString *str, int insert_at, - const unsigned char octets[4]) + const unsigned char octets[2]) { DBUS_STRING_PREAMBLE (str); @@ -1577,19 +1585,11 @@ _dbus_string_split_on_byte (DBusString *source, * * The second check covers surrogate pairs (category Cs). * - * The last two checks cover "Noncharacter": defined as: - * "A code point that is permanently reserved for - * internal use, and that should never be interchanged. In - * Unicode 3.1, these consist of the values U+nFFFE and U+nFFFF - * (where n is from 0 to 10_16) and the values U+FDD0..U+FDEF." - * * @param Char the character */ #define UNICODE_VALID(Char) \ ((Char) < 0x110000 && \ - (((Char) & 0xFFFFF800) != 0xD800) && \ - ((Char) < 0xFDD0 || (Char) > 0xFDEF) && \ - ((Char) & 0xFFFE) != 0xFFFE) + (((Char) & 0xFFFFF800) != 0xD800)) /** * Finds the given substring in the string, @@ -1904,7 +1904,7 @@ _dbus_string_skip_white_reverse (const DBusString *str, * @todo owen correctly notes that this is a stupid function (it was * written purely for test code, * e.g. dbus-message-builder.c). Probably should be enforced as test - * code only with ifdef DBUS_BUILD_TESTS + * code only with ifdef DBUS_ENABLE_EMBEDDED_TESTS * * @param source the source string * @param dest the destination string (contents are replaced) @@ -1948,7 +1948,7 @@ _dbus_string_pop_line (DBusString *source, return TRUE; } -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS /** * Deletes up to and including the first blank space * in the string. @@ -1967,7 +1967,7 @@ _dbus_string_delete_first_word (DBusString *str) } #endif -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS /** * Deletes any leading blanks in the string * @@ -2228,7 +2228,7 @@ _dbus_string_starts_with_c_str (const DBusString *a, */ dbus_bool_t _dbus_string_append_byte_as_hex (DBusString *str, - int byte) + unsigned char byte) { const char hexdigits[16] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',