From 0b0dbbdaab081e559dc969e08378c6e9ef177dd8 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Sat, 30 Aug 2014 12:54:12 -0700 Subject: [PATCH] Prevent queuing input packets before the queue is initialized --- limelight-common/InputStream.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/limelight-common/InputStream.c b/limelight-common/InputStream.c index 7c9611c..ba9bce7 100644 --- a/limelight-common/InputStream.c +++ b/limelight-common/InputStream.c @@ -10,6 +10,7 @@ static IP_ADDRESS host; static SOCKET inputSock = INVALID_SOCKET; static PCONNECTION_LISTENER_CALLBACKS listenerCallbacks; +static int initialized; static LINKED_BLOCKING_QUEUE packetQueue; static PLT_THREAD inputSendThread; @@ -59,6 +60,7 @@ int initializeInputStream(IP_ADDRESS addr, PCONNECTION_LISTENER_CALLBACKS clCall LbqInitializeLinkedBlockingQueue(&packetQueue, 30); + initialized = 1; return 0; } @@ -164,6 +166,10 @@ int LiSendMouseMoveEvent(short deltaX, short deltaY) { PPACKET_HOLDER holder; int err; + if (!initialized) { + return -2; + } + holder = malloc(sizeof(*holder)); if (holder == NULL) { return -1; @@ -187,6 +193,10 @@ int LiSendMouseButtonEvent(char action, int button) { PPACKET_HOLDER holder; int err; + if (!initialized) { + return -2; + } + holder = malloc(sizeof(*holder)); if (holder == NULL) { return -1; @@ -209,6 +219,10 @@ int LiSendKeyboardEvent(short keyCode, char keyAction, char modifiers) { PPACKET_HOLDER holder; int err; + if (!initialized) { + return -2; + } + holder = malloc(sizeof(*holder)); if (holder == NULL) { return -1; @@ -236,6 +250,10 @@ int LiSendControllerEvent(short buttonFlags, char leftTrigger, char rightTrigger PPACKET_HOLDER holder; int err; + if (!initialized) { + return -2; + } + holder = malloc(sizeof(*holder)); if (holder == NULL) { return -1;