From 130094de3244d5039e463e1142e1ec487c1104ef Mon Sep 17 00:00:00 2001
From: Armin Novak <armin.novak@thincast.com>
Date: Tue, 22 Feb 2022 12:05:08 +0100
Subject: [PATCH] Fixed compilation warnings in ainput channel

Upstream-Status: Backport [130094de3 Fixed compilation warnings in ainput channel]
Signed-off-by: Martin Jansa <martin.jansa@gmail.com>
---
 channels/ainput/server/ainput_main.c | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/channels/ainput/server/ainput_main.c b/channels/ainput/server/ainput_main.c
index bc1737ee1..17d2ec681 100644
--- a/channels/ainput/server/ainput_main.c
+++ b/channels/ainput/server/ainput_main.c
@@ -192,7 +192,7 @@ static UINT ainput_server_recv_mouse_event(ainput_server* ainput, wStream* s)
 
 static HANDLE ainput_server_get_channel_handle(ainput_server* ainput)
 {
-	BYTE* buffer = NULL;
+	void* buffer = NULL;
 	DWORD BytesReturned = 0;
 	HANDLE ChannelEvent = NULL;
 
@@ -389,7 +389,7 @@ ainput_server_context* ainput_server_context_new(HANDLE vcm)
 		goto fail;
 	return &ainput->context;
 fail:
-	ainput_server_context_free(ainput);
+	ainput_server_context_free(&ainput->context);
 	return NULL;
 }
 
@@ -496,17 +496,23 @@ UINT ainput_server_context_poll_int(ainput_server_context* context)
 			break;
 		case AINPUT_OPENED:
 		{
-			BYTE* buffer = NULL;
+			union
+			{
+				BYTE* pb;
+				void* pv;
+			} buffer;
 			DWORD BytesReturned = 0;
 
-			if (WTSVirtualChannelQuery(ainput->ainput_channel, WTSVirtualChannelReady, &buffer,
+			buffer.pv = NULL;
+
+			if (WTSVirtualChannelQuery(ainput->ainput_channel, WTSVirtualChannelReady, &buffer.pv,
 			                           &BytesReturned) != TRUE)
 			{
 				WLog_ERR(TAG, "WTSVirtualChannelReady failed,");
 			}
 			else
 			{
-				if (*buffer != 0)
+				if (*buffer.pb != 0)
 				{
 					error = ainput_server_send_version(ainput);
 					if (error)
@@ -518,7 +524,7 @@ UINT ainput_server_context_poll_int(ainput_server_context* context)
 				else
 					error = CHANNEL_RC_OK;
 			}
-			WTSFreeMemory(buffer);
+			WTSFreeMemory(buffer.pv);
 		}
 		break;
 		case AINPUT_VERSION_SENT:
-- 
2.43.0

