Take in account nfedera's review

This commit is contained in:
David FORT 2015-05-20 19:19:50 +02:00
parent f8d6eb226c
commit 29d372480a
7 changed files with 46 additions and 22 deletions

View File

@ -48,6 +48,8 @@ DEVMAN* devman_new(rdpdrPlugin* rdpdr)
DEVMAN* devman;
devman = (DEVMAN*) calloc(1, sizeof(DEVMAN));
if (!devman)
return NULL;
devman->plugin = (void*) rdpdr;
devman->id_sequence = 1;

View File

@ -1151,9 +1151,8 @@ BOOL VCAPITYPE VirtualChannelEntry(PCHANNEL_ENTRY_POINTS pEntryPoints)
rdpsndPlugin* rdpsnd;
rdpsnd = (rdpsndPlugin*) calloc(1, sizeof(rdpsndPlugin));
if (!rdpsnd)
return -1;
return FALSE;
#if !defined(_WIN32) && !defined(ANDROID)
{
@ -1181,7 +1180,7 @@ BOOL VCAPITYPE VirtualChannelEntry(PCHANNEL_ENTRY_POINTS pEntryPoints)
WLog_ERR(TAG, "pVirtualChannelInit failed with %s [%08X]",
WTSErrorToString(rc), rc);
free(rdpsnd);
return -1;
return FALSE;
}
return rdpsnd_add_init_handle_data(rdpsnd->InitHandle, (void*) rdpsnd);

View File

@ -85,7 +85,7 @@ const char* const X11_EVENT_STRINGS[] =
#define DEBUG_X11(fmt, ...) do { } while (0)
#endif
int xf_event_action_script_init(xfContext* xfc)
BOOL xf_event_action_script_init(xfContext* xfc)
{
int exitCode;
char* xevent;
@ -95,7 +95,7 @@ int xf_event_action_script_init(xfContext* xfc)
xfc->xevents = ArrayList_New(TRUE);
if (!xfc->xevents)
return -1;
return FALSE;
ArrayList_Object(xfc->xevents)->fnObjectFree = free;
sprintf_s(command, sizeof(command), "%s xevent", xfc->actionScript);
@ -103,19 +103,19 @@ int xf_event_action_script_init(xfContext* xfc)
actionScript = popen(command, "r");
if (actionScript < 0)
return -1;
return FALSE;
while (fgets(buffer, sizeof(buffer), actionScript))
{
strtok(buffer, "\n");
xevent = _strdup(buffer);
if (ArrayList_Add(xfc->xevents, xevent) < 0)
return -1;
return FALSE;
}
exitCode = pclose(actionScript);
return 1;
return TRUE;
}
void xf_event_action_script_free(xfContext* xfc)

View File

@ -43,7 +43,7 @@
#include <freerdp/log.h>
#define TAG CLIENT_TAG("x11")
int xf_keyboard_action_script_init(xfContext* xfc)
BOOL xf_keyboard_action_script_init(xfContext* xfc)
{
int exitCode;
FILE* keyScript;

View File

@ -684,13 +684,15 @@ HANDLE WINAPI FreeRDP_WTSOpenServerA(LPSTR pServerName)
return INVALID_HANDLE_VALUE;
client = context->peer;
if (!client)
{
SetLastError(ERROR_INVALID_DATA);
return INVALID_HANDLE_VALUE;
}
vcm = (WTSVirtualChannelManager*) calloc(1, sizeof(WTSVirtualChannelManager));
if (!vcm)
return NULL;
goto error_vcm_alloc;
vcm->client = client;
vcm->rdp = context->rdp;
@ -719,7 +721,6 @@ HANDLE WINAPI FreeRDP_WTSOpenServerA(LPSTR pServerName)
client->ReceiveChannelData = WTSReceiveChannelData;
hServer = (HANDLE) vcm;
return hServer;
error_dynamicVirtualChannels:
@ -728,6 +729,8 @@ error_queue:
HashTable_Remove(g_ServerHandles, (void*) (UINT_PTR) vcm->SessionId);
error_free:
free(vcm);
error_vcm_alloc:
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
return INVALID_HANDLE_VALUE;
}
@ -912,15 +915,16 @@ HANDLE WINAPI FreeRDP_WTSVirtualChannelOpen(HANDLE hServer, DWORD SessionId, LPS
HANDLE hChannelHandle = NULL;
vcm = (WTSVirtualChannelManager*) hServer;
if (!vcm)
{
SetLastError(ERROR_INVALID_DATA);
return NULL;
}
client = vcm->client;
mcs = client->context->rdp->mcs;
length = strlen(pVirtualName);
if (length > 8)
{
SetLastError(ERROR_NOT_FOUND);
@ -943,10 +947,11 @@ HANDLE WINAPI FreeRDP_WTSVirtualChannelOpen(HANDLE hServer, DWORD SessionId, LPS
}
channel = (rdpPeerChannel*) mcs->channels[index].handle;
if (!channel)
{
channel = (rdpPeerChannel*) calloc(1, sizeof(rdpPeerChannel));
if (!channel)
goto error_channel_alloc;
channel->vcm = vcm;
channel->client = client;
@ -964,13 +969,13 @@ HANDLE WINAPI FreeRDP_WTSVirtualChannelOpen(HANDLE hServer, DWORD SessionId, LPS
}
hChannelHandle = (HANDLE) channel;
return hChannelHandle;
error_queue:
Stream_Free(channel->receiveData, TRUE);
error_receiveData:
free(channel);
error_channel_alloc:
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
return NULL;
}

View File

@ -95,10 +95,12 @@ BOOL shadow_client_context_new(freerdp_peer* peer, rdpShadowClient* client)
if (!(client->encoder = shadow_encoder_new(client)))
goto fail_encoder_new;
return ArrayList_Add(server->clients, (void*) client) >= 0;
if (ArrayList_Add(server->clients, (void*) client) >= 0)
return TRUE;
shadow_encoder_free(client->encoder);
fail_encoder_new:
CloseHandle(client->encoder);
CloseHandle(client->StopEvent);
client->encoder = NULL;
fail_stop_event:
WTSCloseServer((HANDLE) client->vcm);

View File

@ -571,7 +571,6 @@ PCSC_SCARDHANDLE* PCSC_ConnectCardHandle(SCARDCONTEXT hSharedContext, SCARDCONTE
pCard->hSharedContext = hSharedContext;
pCard->hPrivateContext = hPrivateContext;
pContext->dwCardHandleCount++;
if (!g_CardHandles)
{
@ -583,6 +582,7 @@ PCSC_SCARDHANDLE* PCSC_ConnectCardHandle(SCARDCONTEXT hSharedContext, SCARDCONTE
if (!ListDictionary_Add(g_CardHandles, (void*) hCard, (void*) pCard))
goto error;
pContext->dwCardHandleCount++;
return pCard;
error:
@ -650,13 +650,29 @@ BOOL PCSC_AddReaderNameAlias(char* namePCSC, char* nameWinSCard)
return TRUE;
reader = (PCSC_READER*) calloc(1, sizeof(PCSC_READER));
if (!reader)
return FALSE;
goto error_reader;
reader->namePCSC = _strdup(namePCSC);
if (!reader->namePCSC)
goto error_namePSC;
reader->nameWinSCard = _strdup(nameWinSCard);
return ArrayList_Add(g_Readers, reader) >= 0;
if (!reader->nameWinSCard)
goto error_nameWinSCard;
if (ArrayList_Add(g_Readers, reader) < 0)
goto error_add;
return TRUE;
error_add:
free(reader->nameWinSCard);
error_nameWinSCard:
free(reader->namePCSC);
error_namePSC:
free(reader);
error_reader:
return FALSE;
}
static int PCSC_AtoiWithLength(const char* str, int length)