secur32: check for variable before freeing it
Henri Verbeet
hverbeet at gmail.com
Wed Oct 14 04:07:19 CDT 2009
2009/10/14 Austin English <austinenglish at gmail.com>:
>
> static void *schan_free_handle(ULONG_PTR handle_idx, enum
> schan_handle_type type)
> {
> struct schan_handle *handle;
> void *object;
>
> if (handle_idx == SCHAN_INVALID_HANDLE) return NULL;
> if (handle_idx >= schan_handle_count) return NULL;
>
> Seems NULL comes from 'handle_idx >= schan_handle_count'.
>
How does the attached patch work?
-------------- next part --------------
diff --git a/dlls/secur32/schannel.c b/dlls/secur32/schannel.c
index f776206..a110410 100644
--- a/dlls/secur32/schannel.c
+++ b/dlls/secur32/schannel.c
@@ -1413,13 +1413,13 @@ fail:
void SECUR32_deinitSchannelSP(void)
{
- int i = schan_handle_table_size;
+ SIZE_T i = schan_handle_count;
if (!libgnutls_handle) return;
/* deinitialized sessions first because a pointer to the credentials
* are stored for the session by calling gnutls_credentials_set. */
- while (--i)
+ while (i--)
{
if (schan_handle_table[i].type == SCHAN_HANDLE_CTX)
{
@@ -1428,8 +1428,8 @@ void SECUR32_deinitSchannelSP(void)
HeapFree(GetProcessHeap(), 0, ctx);
}
}
- i = schan_handle_table_size;
- while (--i)
+ i = schan_handle_count;
+ while (i--)
{
if (schan_handle_table[i].type != SCHAN_HANDLE_FREE)
{
More information about the wine-devel
mailing list