Skip to content

Commit 8a619a4

Browse files
committed
Change order of components destruction in umfTearDown
Destroy base alloc last, as other destroy functions might call umf_ba_global_free()
1 parent 664484f commit 8a619a4

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/libumf.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,16 @@ void umfTearDown(void) {
6363
#endif
6464
umfIpcCacheGlobalTearDown();
6565

66+
fini_ze_global_state();
67+
fini_cu_global_state();
68+
LOG_DEBUG("UMF library finalized");
69+
6670
if (utils_is_running_in_proxy_lib_with_size_threshold()) {
6771
// We cannot destroy the TRACKER nor the base allocator
6872
// when we are running in the proxy library with a size threshold,
6973
// because it could result in calling the system free()
7074
// with an invalid pointer and a segfault.
71-
goto fini_umfTearDown;
75+
return;
7276
}
7377

7478
// make sure TRACKER is not used after being destroyed
@@ -79,11 +83,6 @@ void umfTearDown(void) {
7983

8084
umf_ba_destroy_global();
8185
LOG_DEBUG("UMF base allocator destroyed");
82-
83-
fini_umfTearDown:
84-
fini_ze_global_state();
85-
fini_cu_global_state();
86-
LOG_DEBUG("UMF library finalized");
8786
}
8887
}
8988

0 commit comments

Comments
 (0)