[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; LGMP_STATUS status;
LG_RendererCursor cursorType = LG_CURSOR_COLOR; LG_RendererCursor cursorType = LG_CURSOR_COLOR;
KVMFRCursor * cursor = NULL;
lgWaitEvent(e_startup, TIMEOUT_INFINITE); lgWaitEvent(e_startup, TIMEOUT_INFINITE);
@ -377,9 +378,18 @@ int main_cursorThread(void * unused)
} }
/* copy and release the message ASAP */ /* copy and release the message ASAP */
char buffer[msg.size]; if (!cursor)
memcpy(buffer, msg.mem, msg.size); {
KVMFRCursor * cursor = (KVMFRCursor *)buffer; 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); lgmpClientMessageDone(g_state.pointerQueue);
g_cursor.guest.visible = g_cursor.guest.visible =
@ -446,6 +456,14 @@ int main_cursorThread(void * unused)
} }
lgmpClientUnsubscribe(&g_state.pointerQueue); lgmpClientUnsubscribe(&g_state.pointerQueue);
if (cursor)
{
free(cursor);
cursor = NULL;
}
return 0; return 0;
} }