Skip to content

Commit 6074ad8

Browse files
author
Justin Boswell
authored
Ensure bootstrap callback data is allocated/freed with bootstrap's allocator (aws#168)
1 parent b0634ff commit 6074ad8

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

include/aws/crt/io/Bootstrap.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ namespace Aws
8585
private:
8686
aws_client_bootstrap *m_bootstrap;
8787
int m_lastError;
88-
std::unique_ptr<struct ClientBootstrapCallbackData> m_callbackData;
88+
std::unique_ptr<class ClientBootstrapCallbackData> m_callbackData;
8989
std::future<void> m_shutdownFuture;
9090
bool m_enableBlockingShutdown;
9191
};

source/io/Bootstrap.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,13 @@ namespace Aws
1616
* Lives until the bootstrap's shutdown-complete callback fires.
1717
*/
1818
/// @private
19-
struct ClientBootstrapCallbackData
19+
class ClientBootstrapCallbackData
2020
{
21+
private:
22+
Allocator *m_allocator;
23+
24+
public:
25+
ClientBootstrapCallbackData(Allocator *allocator) : m_allocator(allocator) {}
2126
/**
2227
* Promise for bootstrap's shutdown.
2328
*/
@@ -40,7 +45,7 @@ namespace Aws
4045
callbackData->ShutdownCallback();
4146
}
4247

43-
delete callbackData;
48+
Crt::Delete(callbackData, callbackData->m_allocator);
4449
}
4550
};
4651

@@ -49,7 +54,8 @@ namespace Aws
4954
HostResolver &resolver,
5055
Allocator *allocator) noexcept
5156
: m_bootstrap(nullptr), m_lastError(AWS_ERROR_SUCCESS),
52-
m_callbackData(new ClientBootstrapCallbackData()), m_enableBlockingShutdown(false)
57+
m_callbackData(Crt::New<ClientBootstrapCallbackData>(allocator, allocator)),
58+
m_enableBlockingShutdown(false)
5359
{
5460
m_shutdownFuture = m_callbackData->ShutdownPromise.get_future();
5561

0 commit comments

Comments
 (0)