Azure / azure-uamqp-python

AMQP 1.0 client library for Python
MIT License
56 stars 48 forks source link

fix memory leak in c on windows #258

Closed yunhaoling closed 2 years ago

yunhaoling commented 3 years ago
  1. result->addrInfo->ai_addr = calloc(1, sizeof(struct sockaddr_in))) == NULL should no longer exist according to cuamqp echoing the change in PR: https://github.com/Azure/azure-c-shared-utility/pull/515

  1. The PR to fix the following memory leak issue has been merged already: https://github.com/Azure/azure-c-shared-utility/pull/540

https://github.com/Azure/azure-uamqp-python/blob/4558df974fa1a483cf5f0eaf7fe32af465292a50/src/vendor/azure-uamqp-c/deps/azure-c-shared-utility/adapters/tlsio_schannel.c#L298

by:

        FreeContextBuffer(init_security_buffers[0].pvBuffer);
        FreeContextBuffer(init_security_buffers[1].pvBuffer);

because the flag ISC_REQ_ALLOCATE_MEMORY is used in code: https://github.com/Azure/azure-uamqp-python/blob/4558df974fa1a483cf5f0eaf7fe32af465292a50/src/vendor/azure-uamqp-c/deps/azure-c-shared-utility/adapters/tlsio_schannel.c#L365-L368

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.

according to https://docs.microsoft.com/en-us/windows/win32/secauthn/initializesecuritycontext--schannel

yunhaoling commented 3 years ago

created PR in C repo: https://github.com/Azure/azure-c-shared-utility/pull/540