From: Christophe de Dinechin <dinechin@xxxxxxxxxx>
Signed-off-by: Christophe de Dinechin <dinechin@xxxxxxxxxx> --- src/channel-cursor.c | 6 ++++-- src/spice-channel.c | 14 ++++++++------ 2 files changed, 12 insertions(+), 8 deletions(-)
diff --git a/src/channel-cursor.c b/src/channel-cursor.c index 80d2410..4faaa95 100644 --- a/src/channel-cursor.c +++ b/src/channel-cursor.c @@ -385,6 +385,7 @@ static display_cursor *set_cursor(SpiceChannel *channel, SpiceCursor *scursor) const guint8* data; guint8 *rgba; guint8 val; + gint palette[16];
I know that pix is gint too but I think uint32_t is safer.
Will do. But rather guint32, and the change the other variables too for consistency. CHANNEL_DEBUG(channel, "%s: flags %x, size %u", __FUNCTION__, scursor->flags, scursor->data_size); @@ -433,7 +434,7 @@ static display_cursor *set_cursor(SpiceChannel *channel, SpiceCursor *scursor) size /= 2u; for (i = 0; i < hdr->width * hdr->height; i++) { pix_mask = get_pix_mask(data, size, i); - pix = *(SPICE_ALIGNED_CAST(guint16 *, data) + i); + pix = *(SPICE_UNALIGNED_CAST(guint16 *, data) + i); if (pix_mask && pix == 0x7fff) { cursor->data[i] = get_pix_hack(i, hdr->width); } else { @@ -444,10 +445,11 @@ static display_cursor *set_cursor(SpiceChannel *channel, SpiceCursor *scursor) break; case SPICE_CURSOR_TYPE_COLOR4: size = ((unsigned int)(SPICE_ALIGN(hdr->width, 2) / 2)) * hdr->height; + memcpy(palette, data + size, sizeof(palette)); for (i = 0; i < hdr->width * hdr->height; i++) { pix_mask = get_pix_mask(data, size + (sizeof(uint32_t) << 4), i); int idx = (i & 1) ? (data[i >> 1] & 0x0f) : ((data[i >> 1] & 0xf0) >> 4); - pix = *(SPICE_UNALIGNED_CAST(uint32_t *, (data + size)) + idx); + pix = palette[idx]; if (pix_mask && pix == 0xffffff) { cursor->data[i] = get_pix_hack(i, hdr->width); } else { diff --git a/src/spice-channel.c b/src/spice-channel.c index 3b6d839..b196a26 100644 --- a/src/spice-channel.c +++ b/src/spice-channel.c @@ -1931,18 +1931,20 @@ static gboolean spice_channel_recv_link_msg(SpiceChannel *channel) /* g_return_if_fail(c->peer_msg + c->peer_msg->caps_offset * sizeof(uint32_t) > c->peer_msg + c->peer_hdr.size); */
caps_src = (uint8_t *)c->peer_msg + GUINT32_FROM_LE(c->peer_msg->caps_offset); - caps = SPICE_UNALIGNED_CAST(uint32_t *, caps_src); - g_array_set_size(c->remote_common_caps, num_common_caps); + caps = &g_array_index(c->remote_common_caps, uint32_t, 0); + memcpy(caps, caps_src, num_common_caps * sizeof(uint32_t)); for (i = 0; i < num_common_caps; i++, caps++) { - g_array_index(c->remote_common_caps, uint32_t, i) = GUINT32_FROM_LE(*caps); - CHANNEL_DEBUG(channel, "got common caps %d:0x%X", i, GUINT32_FROM_LE(*caps)); + *caps = GUINT32_FROM_LE(*caps); + CHANNEL_DEBUG(channel, "got common caps %d:0x%X", i, *caps); }
g_array_set_size(c->remote_caps, num_channel_caps); + caps_src += num_common_caps * sizeof(uint32_t); + memcpy(caps, caps_src, num_channel_caps * sizeof(uint32_t)); for (i = 0; i < num_channel_caps; i++, caps++) { - g_array_index(c->remote_caps, uint32_t, i) = GUINT32_FROM_LE(*caps); - CHANNEL_DEBUG(channel, "got channel caps %d:0x%X", i, GUINT32_FROM_LE(*caps)); + *caps = GUINT32_FROM_LE(*caps); + CHANNEL_DEBUG(channel, "got channel caps %d:0x%X", i, *caps); }
if (!spice_channel_test_common_capability(channel,
Like these changes but should be merged with the other patch having a singlefix for these hunks.
Coming up.
|