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;
devman = (DEVMAN*) calloc(1, sizeof(DEVMAN)); devman = (DEVMAN*) calloc(1, sizeof(DEVMAN));
if (!devman)
return NULL;
devman->plugin = (void*) rdpdr; devman->plugin = (void*) rdpdr;
devman->id_sequence = 1; devman->id_sequence = 1;

View File

@ -1151,9 +1151,8 @@ BOOL VCAPITYPE VirtualChannelEntry(PCHANNEL_ENTRY_POINTS pEntryPoints)
rdpsndPlugin* rdpsnd; rdpsndPlugin* rdpsnd;
rdpsnd = (rdpsndPlugin*) calloc(1, sizeof(rdpsndPlugin)); rdpsnd = (rdpsndPlugin*) calloc(1, sizeof(rdpsndPlugin));
if (!rdpsnd) if (!rdpsnd)
return -1; return FALSE;
#if !defined(_WIN32) && !defined(ANDROID) #if !defined(_WIN32) && !defined(ANDROID)
{ {
@ -1181,7 +1180,7 @@ BOOL VCAPITYPE VirtualChannelEntry(PCHANNEL_ENTRY_POINTS pEntryPoints)
WLog_ERR(TAG, "pVirtualChannelInit failed with %s [%08X]", WLog_ERR(TAG, "pVirtualChannelInit failed with %s [%08X]",
WTSErrorToString(rc), rc); WTSErrorToString(rc), rc);
free(rdpsnd); free(rdpsnd);
return -1; return FALSE;
} }
return rdpsnd_add_init_handle_data(rdpsnd->InitHandle, (void*) rdpsnd); 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) #define DEBUG_X11(fmt, ...) do { } while (0)
#endif #endif
int xf_event_action_script_init(xfContext* xfc) BOOL xf_event_action_script_init(xfContext* xfc)
{ {
int exitCode; int exitCode;
char* xevent; char* xevent;
@ -95,7 +95,7 @@ int xf_event_action_script_init(xfContext* xfc)
xfc->xevents = ArrayList_New(TRUE); xfc->xevents = ArrayList_New(TRUE);
if (!xfc->xevents) if (!xfc->xevents)
return -1; return FALSE;
ArrayList_Object(xfc->xevents)->fnObjectFree = free; ArrayList_Object(xfc->xevents)->fnObjectFree = free;
sprintf_s(command, sizeof(command), "%s xevent", xfc->actionScript); 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"); actionScript = popen(command, "r");
if (actionScript < 0) if (actionScript < 0)
return -1; return FALSE;
while (fgets(buffer, sizeof(buffer), actionScript)) while (fgets(buffer, sizeof(buffer), actionScript))
{ {
strtok(buffer, "\n"); strtok(buffer, "\n");
xevent = _strdup(buffer); xevent = _strdup(buffer);
if (ArrayList_Add(xfc->xevents, xevent) < 0) if (ArrayList_Add(xfc->xevents, xevent) < 0)
return -1; return FALSE;
} }
exitCode = pclose(actionScript); exitCode = pclose(actionScript);
return 1; return TRUE;
} }
void xf_event_action_script_free(xfContext* xfc) void xf_event_action_script_free(xfContext* xfc)

View File

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

View File

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

View File

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