Hans Leidekker : winhttp: Correct SSL lock size and make sure we free as many as we allocated.
Alexandre Julliard
julliard at winehq.org
Wed Oct 21 13:14:10 CDT 2009
Module: wine
Branch: master
Commit: 6732d5dfd71bb615467b92f29659e172bef81c52
URL: http://source.winehq.org/git/wine.git/?a=commit;h=6732d5dfd71bb615467b92f29659e172bef81c52
Author: Hans Leidekker <hans at codeweavers.com>
Date: Wed Oct 21 13:18:43 2009 +0200
winhttp: Correct SSL lock size and make sure we free as many as we allocated.
Found by valgrind.
---
dlls/winhttp/net.c | 11 +++++------
1 files changed, 5 insertions(+), 6 deletions(-)
diff --git a/dlls/winhttp/net.c b/dlls/winhttp/net.c
index 6e54348..28b3972 100644
--- a/dlls/winhttp/net.c
+++ b/dlls/winhttp/net.c
@@ -120,6 +120,7 @@ MAKE_FUNCPTR( i2d_X509 );
#undef MAKE_FUNCPTR
static CRITICAL_SECTION *ssl_locks;
+static unsigned int num_ssl_locks;
static unsigned long ssl_thread_id(void)
{
@@ -290,16 +291,15 @@ BOOL netconn_init( netconn_t *conn, BOOL secure )
}
pCRYPTO_set_id_callback(ssl_thread_id);
- ssl_locks = HeapAlloc(GetProcessHeap(), 0,
- pCRYPTO_num_locks() * sizeof(HANDLE));
+ num_ssl_locks = pCRYPTO_num_locks();
+ ssl_locks = HeapAlloc(GetProcessHeap(), 0, num_ssl_locks * sizeof(CRITICAL_SECTION));
if (!ssl_locks)
{
set_last_error( ERROR_OUTOFMEMORY );
LeaveCriticalSection( &init_ssl_cs );
return FALSE;
}
- for (i = 0; i < pCRYPTO_num_locks(); i++)
- InitializeCriticalSection( &ssl_locks[i] );
+ for (i = 0; i < num_ssl_locks; i++) InitializeCriticalSection( &ssl_locks[i] );
pCRYPTO_set_locking_callback(ssl_lock_callback);
LeaveCriticalSection( &init_ssl_cs );
@@ -320,8 +320,7 @@ void netconn_unload( void )
{
int i;
- for (i = 0; i < pCRYPTO_num_locks(); i++)
- DeleteCriticalSection( &ssl_locks[i] );
+ for (i = 0; i < num_ssl_locks; i++) DeleteCriticalSection( &ssl_locks[i] );
HeapFree( GetProcessHeap(), 0, ssl_locks );
}
wine_dlclose( libcrypto_handle, NULL, 0 );
More information about the wine-cvs
mailing list