Skip to content

Commit

Permalink
fix crash
Browse files Browse the repository at this point in the history
  • Loading branch information
waker authored and waker committed Dec 29, 2023
1 parent 51d16d8 commit 6feb91d
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions plugins/notify/notify.c
Original file line number Diff line number Diff line change
Expand Up @@ -301,14 +301,15 @@ 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;
dbus_int32_t stride;
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;
Expand All @@ -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;

Expand All @@ -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,
Expand All @@ -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;
Expand All @@ -370,21 +371,24 @@ 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);
dbus_message_iter_append_basic (&image_sub, DBUS_TYPE_BOOLEAN, &image_data.has_alpha);
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);
}
Expand All @@ -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) {
Expand Down

0 comments on commit 6feb91d

Please sign in to comment.