From 98b0f37020fdb84716887db52eff01744218169b Mon Sep 17 00:00:00 2001 From: Armin Novak Date: Wed, 11 Mar 2015 18:09:22 +0100 Subject: [PATCH] Initializing handles with calloc now. --- winpr/libwinpr/pipe/pipe.c | 4 ++-- winpr/libwinpr/sspicli/sspicli.c | 4 +--- winpr/libwinpr/synch/mutex.c | 2 +- winpr/libwinpr/synch/semaphore.c | 2 +- 4 files changed, 5 insertions(+), 7 deletions(-) diff --git a/winpr/libwinpr/pipe/pipe.c b/winpr/libwinpr/pipe/pipe.c index 74915088b..6b95cf8ef 100644 --- a/winpr/libwinpr/pipe/pipe.c +++ b/winpr/libwinpr/pipe/pipe.c @@ -138,8 +138,8 @@ BOOL CreatePipe(PHANDLE hReadPipe, PHANDLE hWritePipe, LPSECURITY_ATTRIBUTES lpP return FALSE; } - pReadPipe = (WINPR_PIPE*) malloc(sizeof(WINPR_PIPE)); - pWritePipe = (WINPR_PIPE*) malloc(sizeof(WINPR_PIPE)); + pReadPipe = (WINPR_PIPE*) calloc(1, sizeof(WINPR_PIPE)); + pWritePipe = (WINPR_PIPE*) calloc(1, sizeof(WINPR_PIPE)); if (!pReadPipe || !pWritePipe) { diff --git a/winpr/libwinpr/sspicli/sspicli.c b/winpr/libwinpr/sspicli/sspicli.c index ae26f34e2..be31b8ab9 100644 --- a/winpr/libwinpr/sspicli/sspicli.c +++ b/winpr/libwinpr/sspicli/sspicli.c @@ -123,13 +123,11 @@ BOOL LogonUserA(LPCSTR lpszUsername, LPCSTR lpszDomain, LPCSTR lpszPassword, if (!lpszUsername) return FALSE; - token = (WINPR_ACCESS_TOKEN*) malloc(sizeof(WINPR_ACCESS_TOKEN)); + token = (WINPR_ACCESS_TOKEN*) calloc(1, sizeof(WINPR_ACCESS_TOKEN)); if (!token) return FALSE; - ZeroMemory(token, sizeof(WINPR_ACCESS_TOKEN)); - WINPR_HANDLE_SET_TYPE(token, HANDLE_TYPE_ACCESS_TOKEN); token->cb.GetFd = LogonUserGetFd; diff --git a/winpr/libwinpr/synch/mutex.c b/winpr/libwinpr/synch/mutex.c index b11e2bf00..251229384 100644 --- a/winpr/libwinpr/synch/mutex.c +++ b/winpr/libwinpr/synch/mutex.c @@ -73,7 +73,7 @@ HANDLE CreateMutexW(LPSECURITY_ATTRIBUTES lpMutexAttributes, BOOL bInitialOwner, HANDLE handle = NULL; WINPR_MUTEX* mutex; - mutex = (WINPR_MUTEX*) malloc(sizeof(WINPR_MUTEX)); + mutex = (WINPR_MUTEX*) calloc(1, sizeof(WINPR_MUTEX)); if (mutex) { diff --git a/winpr/libwinpr/synch/semaphore.c b/winpr/libwinpr/synch/semaphore.c index 7796227bd..4e05ebf4e 100644 --- a/winpr/libwinpr/synch/semaphore.c +++ b/winpr/libwinpr/synch/semaphore.c @@ -116,7 +116,7 @@ HANDLE CreateSemaphoreW(LPSECURITY_ATTRIBUTES lpSemaphoreAttributes, LONG lIniti HANDLE handle; WINPR_SEMAPHORE* semaphore; - semaphore = (WINPR_SEMAPHORE*) malloc(sizeof(WINPR_SEMAPHORE)); + semaphore = (WINPR_SEMAPHORE*) calloc(1, sizeof(WINPR_SEMAPHORE)); if (!semaphore) return NULL;