secur32: Use ~0UL instead of -1 for invalid schannel handles.

This commit is contained in:
Henri Verbeet 2008-10-06 19:08:36 +02:00 committed by Alexandre Julliard
parent abe7846a94
commit 79d88ffe56
1 changed files with 7 additions and 5 deletions

View File

@ -48,6 +48,8 @@ MAKE_FUNCPTR(gnutls_global_set_log_function);
MAKE_FUNCPTR(gnutls_global_set_log_level); MAKE_FUNCPTR(gnutls_global_set_log_level);
#undef MAKE_FUNCPTR #undef MAKE_FUNCPTR
#define SCHAN_INVALID_HANDLE ~0UL
enum schan_handle_type enum schan_handle_type
{ {
SCHAN_HANDLE_CRED, SCHAN_HANDLE_CRED,
@ -82,7 +84,7 @@ static ULONG_PTR schan_alloc_handle(void *object, enum schan_handle_type type)
if (handle->type != SCHAN_HANDLE_FREE) if (handle->type != SCHAN_HANDLE_FREE)
{ {
ERR("Handle %d(%p) is in the free list, but has type %#x.\n", (handle-schan_handle_table), handle, handle->type); ERR("Handle %d(%p) is in the free list, but has type %#x.\n", (handle-schan_handle_table), handle, handle->type);
return -1; return SCHAN_INVALID_HANDLE;
} }
schan_free_handles = (struct schan_handle *)handle->object; schan_free_handles = (struct schan_handle *)handle->object;
handle->object = object; handle->object = object;
@ -98,7 +100,7 @@ static ULONG_PTR schan_alloc_handle(void *object, enum schan_handle_type type)
if (!new_table) if (!new_table)
{ {
ERR("Failed to grow the handle table\n"); ERR("Failed to grow the handle table\n");
return -1; return SCHAN_INVALID_HANDLE;
} }
schan_handle_table = new_table; schan_handle_table = new_table;
schan_handle_table_size = new_size; schan_handle_table_size = new_size;
@ -116,7 +118,7 @@ static void *schan_free_handle(ULONG_PTR handle_idx, enum schan_handle_type type
struct schan_handle *handle; struct schan_handle *handle;
void *object; void *object;
if (handle_idx == -1) return NULL; if (handle_idx == SCHAN_INVALID_HANDLE) return NULL;
handle = &schan_handle_table[handle_idx]; handle = &schan_handle_table[handle_idx];
if (handle->type != type) if (handle->type != type)
{ {
@ -283,7 +285,7 @@ static SECURITY_STATUS schan_AcquireClientCredentials(const SCHANNEL_CRED *schan
if (!creds) return SEC_E_INSUFFICIENT_MEMORY; if (!creds) return SEC_E_INSUFFICIENT_MEMORY;
handle = schan_alloc_handle(creds, SCHAN_HANDLE_CRED); handle = schan_alloc_handle(creds, SCHAN_HANDLE_CRED);
if (handle == -1) if (handle == SCHAN_INVALID_HANDLE)
{ {
HeapFree(GetProcessHeap(), 0, creds); HeapFree(GetProcessHeap(), 0, creds);
return SEC_E_INTERNAL_ERROR; return SEC_E_INTERNAL_ERROR;
@ -325,7 +327,7 @@ static SECURITY_STATUS schan_AcquireServerCredentials(const SCHANNEL_CRED *schan
creds->credential_use = SECPKG_CRED_INBOUND; creds->credential_use = SECPKG_CRED_INBOUND;
handle = schan_alloc_handle(creds, SCHAN_HANDLE_CRED); handle = schan_alloc_handle(creds, SCHAN_HANDLE_CRED);
if (handle == -1) if (handle == SCHAN_INVALID_HANDLE)
{ {
HeapFree(GetProcessHeap(), 0, creds); HeapFree(GetProcessHeap(), 0, creds);
return SEC_E_INTERNAL_ERROR; return SEC_E_INTERNAL_ERROR;