winpr: small fixes and cleanups

Update the pull request and integrate the latest comments and
suggestions.

* TestLibrary*: fix typo in error message
* TestPipeCreateNamedPipeOverlapped: free possibly allocated memory
* smartcard_pcsc.c: format fix
* process.c: add missing NULL check
* MessageQueue.c: delete possibly initialized critical section on error
This commit is contained in:
Bernhard Miklautz 2015-04-07 14:38:09 +02:00
parent 12e1d94567
commit a8c44f15c0
7 changed files with 15 additions and 6 deletions

View File

@ -22,7 +22,7 @@ int TestLibraryFreeLibrary(int argc, char* argv[])
BasePath = (WCHAR*) malloc((length + 1) * sizeof(WCHAR));
if (!BasePath)
{
_tprintf(_T("Memory allocation falied\n"));
_tprintf(_T("Memory allocation failed\n"));
return -1;
}
MultiByteToWideChar(CP_UTF8, 0, str, length, (LPWSTR) BasePath, length * sizeof(WCHAR));

View File

@ -27,7 +27,7 @@ int TestLibraryGetProcAddress(int argc, char* argv[])
BasePath = (WCHAR*) malloc((length + 1) * sizeof(WCHAR));
if (!BasePath)
{
_tprintf(_T("Memory allocation falied\n"));
_tprintf(_T("Memory allocation failed\n"));
return -1;
}
MultiByteToWideChar(CP_UTF8, 0, str, length, (LPWSTR) BasePath, length * sizeof(WCHAR));

View File

@ -22,7 +22,7 @@ int TestLibraryLoadLibrary(int argc, char* argv[])
BasePath = (WCHAR*) malloc((length + 1) * sizeof(WCHAR));
if (!BasePath)
{
_tprintf(_T("Memory allocation falied\n"));
_tprintf(_T("Memory allocation failed\n"));
return -1;
}
MultiByteToWideChar(CP_UTF8, 0, str, length, (LPWSTR) BasePath, length * sizeof(WCHAR));

View File

@ -48,6 +48,8 @@ static void* named_pipe_client_thread(void* arg)
if (!lpReadBuffer || !lpWriteBuffer)
{
printf("Error allocating memory\n");
free(lpReadBuffer);
free(lpWriteBuffer);
return NULL;
}
ZeroMemory(&overlapped, sizeof(OVERLAPPED));
@ -161,6 +163,8 @@ static void* named_pipe_server_thread(void* arg)
if (!lpReadBuffer || !lpWriteBuffer)
{
printf("Error allocating memory\n");
free(lpReadBuffer);
free(lpWriteBuffer);
return NULL;
}
nNumberOfBytesToRead = PIPE_BUFFER_SIZE;

View File

@ -2963,9 +2963,7 @@ int PCSC_InitializeSCardApi(void)
{
env = (LPSTR) malloc(nSize);
if (!env)
{
return -1;
}
nSize = GetEnvironmentVariableA("WINPR_WINSCARD_LOCK_TRANSACTIONS", env, nSize);
if (strcmp(env, "1") == 0)

View File

@ -230,6 +230,8 @@ BOOL _CreateProcessExA(HANDLE hToken, DWORD dwLogonFlags,
else
{
lpszEnvironmentBlock = GetEnvironmentStrings();
if (lpszEnvironmentBlock)
goto finish;
envp = EnvironmentBlockToEnvpA(lpszEnvironmentBlock);
}
if (!envp)

View File

@ -203,11 +203,16 @@ wMessageQueue* MessageQueue_New(const wObject *callback)
return NULL;
}
InitializeCriticalSectionAndSpinCount(&queue->lock, 4000);
if (!InitializeCriticalSectionAndSpinCount(&queue->lock, 4000))
{
free(queue);
return NULL;
}
queue->event = CreateEvent(NULL, TRUE, FALSE, NULL);
if (!queue->event)
{
free(queue->array);
DeleteCriticalSection(&queue->lock);
free(queue);
return NULL;
}