diff options
-rw-r--r-- | src/realmd/rdcp_dbus.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/realmd/rdcp_dbus.c b/src/realmd/rdcp_dbus.c index 75ee439..3df6803 100644 --- a/src/realmd/rdcp_dbus.c +++ b/src/realmd/rdcp_dbus.c @@ -181,6 +181,9 @@ dbus_message_print_byte_array(GString *string, DBusMessageIter *iter, int depth) dbus_bool_t all_ascii = TRUE; int current_type; + if (!bytes) + return; + while ((current_type = dbus_message_iter_get_arg_type (iter)) != DBUS_TYPE_INVALID) { unsigned char val; @@ -192,8 +195,12 @@ dbus_message_print_byte_array(GString *string, DBusMessageIter *iter, int depth) all_ascii = FALSE; if (len == max) { + unsigned char *tmp_bytes; + max *= 2; - bytes = realloc(bytes, max + 1); + if (!(tmp_bytes = realloc(bytes, max + 1))) + goto fail; + bytes = tmp_bytes; } dbus_message_iter_next (iter); @@ -206,6 +213,7 @@ dbus_message_print_byte_array(GString *string, DBusMessageIter *iter, int depth) dbus_message_print_hex(string, bytes, len, depth); } +fail: free (bytes); } |