Fix a few unhooked allocations (#730)
When creating a std::shared_ptr<> from a raw pointer, we need to pass in both a custom deleter and allocator. Though the object itself is already allocated, std::shared_ptr<> allocates some internal data on top of that. More details here: https://en.cppreference.com/w/cpp/memory/shared_ptr/shared_ptr.
This commit is contained in:
Родитель
41e4e73cc1
Коммит
798f603084
|
@ -80,7 +80,7 @@ Result<std::shared_ptr<WinHttpConnection>> WinHttpConnection::Initialize(
|
|||
RETURN_HR_IF(E_INVALIDARG, !call);
|
||||
|
||||
http_stl_allocator<WinHttpConnection> a{};
|
||||
auto connection = std::shared_ptr<WinHttpConnection>{ new (a.allocate(1)) WinHttpConnection(hSession, call, proxyType, std::move(securityInformation)), http_alloc_deleter<WinHttpConnection>() };
|
||||
auto connection = std::shared_ptr<WinHttpConnection>{ new (a.allocate(1)) WinHttpConnection(hSession, call, proxyType, std::move(securityInformation)), http_alloc_deleter<WinHttpConnection>(), a };
|
||||
RETURN_IF_FAILED(connection->Initialize());
|
||||
|
||||
return connection;
|
||||
|
|
|
@ -13,7 +13,7 @@ NAMESPACE_XBOX_HTTP_CLIENT_BEGIN
|
|||
Result<std::shared_ptr<WinHttpProvider>> WinHttpProvider::Initialize()
|
||||
{
|
||||
http_stl_allocator<WinHttpProvider> a{};
|
||||
auto provider = std::shared_ptr<WinHttpProvider>{ new (a.allocate(1)) WinHttpProvider, http_alloc_deleter<WinHttpProvider>() };
|
||||
auto provider = std::shared_ptr<WinHttpProvider>{ new (a.allocate(1)) WinHttpProvider, http_alloc_deleter<WinHttpProvider>(), a };
|
||||
|
||||
RETURN_IF_FAILED(XTaskQueueCreate(XTaskQueueDispatchMode::Immediate, XTaskQueueDispatchMode::Immediate, &provider->m_immediateQueue));
|
||||
|
||||
|
|
|
@ -129,7 +129,7 @@ Result<std::shared_ptr<WebSocket>> WebSocket::Initialize()
|
|||
++httpSingleton->m_lastId,
|
||||
httpSingleton->m_websocketPerform,
|
||||
httpSingleton->m_performEnv.get()
|
||||
}, http_alloc_deleter<WebSocket>{} };
|
||||
}, http_alloc_deleter<WebSocket>{}, a };
|
||||
|
||||
return websocket;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче