From 6feb91d436edb053c3393d513ebd84ada425342e Mon Sep 17 00:00:00 2001 From: waker Date: Fri, 29 Dec 2023 11:52:04 +0100 Subject: [PATCH] fix crash --- plugins/notify/notify.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/plugins/notify/notify.c b/plugins/notify/notify.c index 3b846d617c..6c0dedb193 100644 --- a/plugins/notify/notify.c +++ b/plugins/notify/notify.c @@ -301,6 +301,8 @@ show_notification (DB_playItem_t *track, char *image_filename, dbus_uint32_t rep // GdkPixbuf *img = _load_image_from_cover(image_filename); + uint32_t *image_bytes = malloc(16); + struct { dbus_int32_t width; dbus_int32_t height; @@ -308,7 +310,6 @@ show_notification (DB_playItem_t *track, char *image_filename, dbus_uint32_t rep dbus_bool_t has_alpha; dbus_int32_t bits_per_sample; dbus_int32_t channels; - uint32_t bytes[4]; } image_data; image_data.width = 2; @@ -317,10 +318,10 @@ show_notification (DB_playItem_t *track, char *image_filename, dbus_uint32_t rep image_data.has_alpha = 0; image_data.bits_per_sample = 32; image_data.channels = 4; - image_data.bytes[0] = 0x00000000; - image_data.bytes[1] = 0xffffffff; - image_data.bytes[2] = 0x00000000; - image_data.bytes[3] = 0xffffffff; + image_bytes[0] = 0x00000000; + image_bytes[1] = 0xffffffff; + image_bytes[2] = 0x00000000; + image_bytes[3] = 0xffffffff; DBusMessageIter iter, sub; @@ -332,7 +333,7 @@ show_notification (DB_playItem_t *track, char *image_filename, dbus_uint32_t rep &replaces_id, DBUS_TYPE_STRING, &v_iconname, - DBUS_TYPE_VARIANT, + DBUS_TYPE_STRING, &v_summary, DBUS_TYPE_STRING, &v_body, @@ -356,7 +357,7 @@ show_notification (DB_playItem_t *track, char *image_filename, dbus_uint32_t rep // image data needs to be inserted here, under image-data key // NOTE: it's not guaranteed that image-data hint is supported by all notification daemons - const char v_image_data[] = "image-data"; + char *v_image_data = "image-data"; dbus_message_iter_append_basic (&dict_entry_sub, DBUS_TYPE_STRING, &v_image_data); DBusMessageIter value_sub; @@ -370,8 +371,6 @@ show_notification (DB_playItem_t *track, char *image_filename, dbus_uint32_t rep { - DBusMessageIter data_sub; - dbus_message_iter_append_basic (&image_sub, DBUS_TYPE_INT32, &image_data.width); dbus_message_iter_append_basic (&image_sub, DBUS_TYPE_INT32, &image_data.height); dbus_message_iter_append_basic (&image_sub, DBUS_TYPE_INT32, &image_data.stride); @@ -379,12 +378,17 @@ show_notification (DB_playItem_t *track, char *image_filename, dbus_uint32_t rep dbus_message_iter_append_basic (&image_sub, DBUS_TYPE_INT32, &image_data.bits_per_sample); dbus_message_iter_append_basic (&image_sub, DBUS_TYPE_INT32, &image_data.channels); + DBusMessageIter data_sub; + dbus_message_iter_open_container ( &image_sub, DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE_AS_STRING, &data_sub); - { dbus_message_iter_append_fixed_array (&data_sub, DBUS_TYPE_BYTE, &image_data.bytes, 16); } + + { + dbus_message_iter_append_fixed_array (&data_sub, DBUS_TYPE_BYTE, &image_bytes, 16); + } dbus_message_iter_close_container (&image_sub, &data_sub); } @@ -403,6 +407,8 @@ show_notification (DB_playItem_t *track, char *image_filename, dbus_uint32_t rep dbus_message_iter_append_basic (&iter, DBUS_TYPE_INT32, &v_timeout); replaces_id = notify_send (msg, replaces_id); + + free (image_bytes); } if (should_wait_for_cover) {