Skip to content

Commit 9b22721

Browse files
committed
fix umfDisjointPoolParamsDestroy
1 parent 97161cf commit 9b22721

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

src/base_alloc/base_alloc_global.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ void umf_ba_destroy_global(void) {
5555
memcpy(&ba_is_initialized, &set_once, sizeof(ba_is_initialized));
5656
}
5757

58-
bool umf_ba_global_is_destroyed() { return ba_is_destroyed; }
58+
bool umf_ba_global_is_destroyed(void) { return ba_is_destroyed; }
5959

6060
static void umf_ba_create_global(void) {
6161
for (int i = 0; i < NUM_ALLOCATION_CLASSES; i++) {

src/base_alloc/base_alloc_global.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ extern "C" {
1919
void *umf_ba_global_alloc(size_t size);
2020
void umf_ba_global_free(void *ptr);
2121
void umf_ba_destroy_global(void);
22-
bool umf_ba_global_is_destroyed();
22+
bool umf_ba_global_is_destroyed(void);
2323
size_t umf_ba_global_malloc_usable_size(void *ptr);
2424
void *umf_ba_global_aligned_alloc(size_t size, size_t alignment);
2525

src/pool/pool_disjoint.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1098,7 +1098,8 @@ umfDisjointPoolParamsCreate(umf_disjoint_pool_params_handle_t *hParams) {
10981098

10991099
umf_result_t
11001100
umfDisjointPoolParamsDestroy(umf_disjoint_pool_params_handle_t hParams) {
1101-
if (hParams) {
1101+
// NOTE: dereferencing hParams when BA is already destroyed leads to crash
1102+
if (hParams && !umf_ba_global_is_destroyed()) {
11021103
umf_ba_global_free(hParams->name);
11031104
umf_ba_global_free(hParams);
11041105
}

0 commit comments

Comments
 (0)