[client] main: malloc buffer for cursor data instead of using the stack

This commit is contained in:
Geoffrey McRae 2021-11-01 13:44:46 +11:00
parent b515fa80d5
commit e82f8911a6

View File

@ -304,6 +304,7 @@ int main_cursorThread(void * unused)
{
LGMP_STATUS status;
LG_RendererCursor cursorType = LG_CURSOR_COLOR;
KVMFRCursor * cursor = NULL;
lgWaitEvent(e_startup, TIMEOUT_INFINITE);
@ -377,9 +378,18 @@ int main_cursorThread(void * unused)
}
/* copy and release the message ASAP */
char buffer[msg.size];
memcpy(buffer, msg.mem, msg.size);
KVMFRCursor * cursor = (KVMFRCursor *)buffer;
if (!cursor)
{
cursor = malloc(msg.size);
if (!cursor)
{
DEBUG_ERROR("failed to allocate %d bytes for cursor", msg.size);
g_state.state = APP_STATE_SHUTDOWN;
break;
}
}
memcpy(cursor, msg.mem, msg.size);
lgmpClientMessageDone(g_state.pointerQueue);
g_cursor.guest.visible =
@ -446,6 +456,14 @@ int main_cursorThread(void * unused)
}
lgmpClientUnsubscribe(&g_state.pointerQueue);
if (cursor)
{
free(cursor);
cursor = NULL;
}
return 0;
}