Skip to content

Commit 0d6f12f

Browse files
committed
fix allocator size=0
1 parent a508bf9 commit 0d6f12f

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

lib/allocator.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,10 @@ void pool_reset() {
105105

106106
//----------------------------------------------------------------------------------------
107107
void* pool_alloc(size_t size) {
108+
if (size == 0) {
109+
return nullptr;
110+
}
111+
108112
auto& storage = get_storage();
109113
auto& allocmap = get_allocmap();
110114

@@ -139,6 +143,10 @@ void* pool_alloc(size_t size) {
139143

140144
//----------------------------------------------------------------------------------------
141145
void pool_free(void* ptr) {
146+
if (ptr == nullptr) {
147+
return;
148+
}
149+
142150
auto& storage = get_storage();
143151
auto& allocmap = get_allocmap();
144152

0 commit comments

Comments
 (0)