Fixed leaks in rdg_send_channel_create
@@ -367,23 +367,19 @@ static BOOL rdg_send_tunnel_authorization(rdpRdg* rdg)
static BOOL rdg_send_channel_create(rdpRdg* rdg)
{
- size_t i;
- wStream* s;
- BOOL status;
+ wStream* s = NULL;
+ BOOL status = FALSE;
WCHAR* serverName = NULL;
int serverNameLen = ConvertToUnicode(CP_UTF8, 0, rdg->settings->ServerHostname, -1, &serverName, 0);
UINT32 packetSize = 16 + ((UINT32)serverNameLen) * 2;
if ((serverNameLen < 0) || (serverNameLen > UINT16_MAX / 2))
- {
- free(serverName);
- return FALSE;
- }
+ goto fail;
s = Stream_New(NULL, packetSize);
if (!s)
- return FALSE;
+ goto fail;
Stream_Write_UINT16(s, PKT_TYPE_CHANNEL_CREATE); /* Type (2 bytes) */
Stream_Write_UINT16(s, 0); /* Reserved (2 bytes) */
@@ -396,12 +392,12 @@ static BOOL rdg_send_channel_create(rdpRdg* rdg)
Stream_Write_UTF16_String(s, serverName, (size_t)serverNameLen);
Stream_SealLength(s);
status = rdg_write_packet(rdg, s);
+fail:
+ free(serverName);
Stream_Free(s, TRUE);
if (status)
- {
rdg->state = RDG_CLIENT_STATE_CHANNEL_CREATE;
- }
return status;
}
