Skip to content

Commit 338e95c

Browse files
authored
Merge pull request #2550 from BusyJay/BusyJay-patch-1
test/iobuf: fix mismatch deallocation
2 parents 8b340f9 + ad70b7f commit 338e95c

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

src/butil/iobuf.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,13 @@ inline void* cp(void *__restrict dest, const void *__restrict src, size_t n) {
164164
void* (*blockmem_allocate)(size_t) = ::malloc;
165165
void (*blockmem_deallocate)(void*) = ::free;
166166

167+
void remove_tls_block_chain();
168+
167169
// Use default function pointers
168170
void reset_blockmem_allocate_and_deallocate() {
171+
// There maybe block allocated by previous hooks, it's wrong to free them using
172+
// mismatched hook.
173+
remove_tls_block_chain();
169174
blockmem_allocate = ::malloc;
170175
blockmem_deallocate = ::free;
171176
}

0 commit comments

Comments
 (0)