cursor: Consistently use g_memdup() for cursor data

Currently, red-parse-qxl.c uses g_malloc+memcpy to duplicate the cursor
data when it could use g_memdup() instead. red-stream-device.c does the
same thing but uses spice_memdup(). This commit makes use of g_memdup()
in both cases so that this memory is consistently allocated through
glib.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
This commit is contained in:
Christophe Fergeau 2018-04-05 10:30:00 +02:00
parent 8e302a7596
commit 216bf191b8
2 changed files with 2 additions and 3 deletions

View File

@ -1450,8 +1450,7 @@ static bool red_get_cursor(RedMemSlotInfo *slots, int group_id,
if (free_data) {
red->data = data;
} else {
red->data = g_malloc(size);
memcpy(red->data, data, size);
red->data = g_memdup(data, size);
}
return true;
}

View File

@ -344,7 +344,7 @@ stream_msg_cursor_set_to_cursor_cmd(const StreamMsgCursorSet *msg, size_t msg_si
return NULL;
}
cursor->data_size = size_required;
cursor->data = spice_memdup(msg->data, size_required);
cursor->data = g_memdup(msg->data, size_required);
return cmd;
}