Skip to content

Commit d6470fc

Browse files
authored
Merge pull request #794 from vinser52/svinogra.minor_fixes
Fix umfPoolDestroy to destroy providers in the right order
2 parents 0cac080 + 439ea94 commit d6470fc

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/memory_pool.c

+8-6
Original file line numberDiff line numberDiff line change
@@ -76,18 +76,20 @@ static umf_result_t umfPoolCreateInternal(const umf_memory_pool_ops_t *ops,
7676

7777
void umfPoolDestroy(umf_memory_pool_handle_t hPool) {
7878
hPool->ops.finalize(hPool->pool_priv);
79-
if (hPool->flags & UMF_POOL_CREATE_FLAG_OWN_PROVIDER) {
80-
// Destroy associated memory provider.
81-
umf_memory_provider_handle_t hProvider = NULL;
82-
umfPoolGetMemoryProvider(hPool, &hProvider);
83-
umfMemoryProviderDestroy(hProvider);
84-
}
79+
80+
umf_memory_provider_handle_t hUpstreamProvider = NULL;
81+
umfPoolGetMemoryProvider(hPool, &hUpstreamProvider);
8582

8683
if (!(hPool->flags & UMF_POOL_CREATE_FLAG_DISABLE_TRACKING)) {
8784
// Destroy tracking provider.
8885
umfMemoryProviderDestroy(hPool->provider);
8986
}
9087

88+
if (hPool->flags & UMF_POOL_CREATE_FLAG_OWN_PROVIDER) {
89+
// Destroy associated memory provider.
90+
umfMemoryProviderDestroy(hUpstreamProvider);
91+
}
92+
9193
LOG_INFO("Memory pool destroyed: %p", (void *)hPool);
9294

9395
// TODO: this free keeps memory in base allocator, so it can lead to OOM in some scenarios (it should be optimized)

0 commit comments

Comments
 (0)