hey team, proposing a PR to fix some memory leak issues in the tlsio_schannel.c, not sure if it's the best fix, but after the fix, there's no memory leak in my test.
potential memory leak:
should tls_io_instance->credential_handle also be freed if (status != SEC_E_OK)?
as mentioned by the schannel doc: When you have finished using the returned credentials, free the memory used by the credentials by calling the FreeCredentialsHandle function.
definite memory leak: output buffer in multiple InitializeSecurityContext call:
according to the schannel doc: With flag ISC_REQ_ALLOCATE_MEMORY, The [*security package*](../secgloss/s-gly.md) allocates output buffers for you. When you have finished using the output buffers, free them by calling the [FreeContextBuffer](/windows/win32/api/sspi/nf-sspi-freecontextbuffer) function.
in this case, we should call FreeContextBuffer to free the buffer after usage
hey team, proposing a PR to fix some memory leak issues in the tlsio_schannel.c, not sure if it's the best fix, but after the fix, there's no memory leak in my test.
tls_io_instance->credential_handle
also be freedif (status != SEC_E_OK)
?When you have finished using the returned credentials, free the memory used by the credentials by calling the FreeCredentialsHandle function.
https://github.com/Azure/azure-c-shared-utility/blob/master/adapters/tlsio_schannel.c#L341-L347
definite memory leak: output buffer in multiple
InitializeSecurityContext
call:ISC_REQ_ALLOCATE_MEMORY
,The [*security package*](../secgloss/s-gly.md) allocates output buffers for you. When you have finished using the output buffers, free them by calling the [FreeContextBuffer](/windows/win32/api/sspi/nf-sspi-freecontextbuffer) function.
FreeContextBuffer
to free the buffer after usageleaking places:
https://github.com/Azure/azure-c-shared-utility/blob/master/adapters/tlsio_schannel.c#L363-L367
https://github.com/Azure/azure-c-shared-utility/blob/master/adapters/tlsio_schannel.c#L656-L660
https://github.com/Azure/azure-c-shared-utility/blob/master/adapters/tlsio_schannel.c#L938-L942