Skip to content

Commit ad70b7f

Browse files
authored
test/iobuf: fix mismatch deallocation
In tests there are some places that doesn't clear previous allocated block before resetting allocation hooks and lead to asan error.
1 parent 24fc31e commit ad70b7f

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)