Skip to content

Commit 7e498d2

Browse files
committed
fix empty Tensor mmap
1 parent 703ccbb commit 7e498d2

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

THAllocator.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,10 @@ void THMapAllocatorContext_free(THMapAllocatorContext *ctx)
105105

106106
static void *_map_alloc(void* ctx_, ptrdiff_t size)
107107
{
108+
if (size == 0) {
109+
return NULL;
110+
}
111+
108112
THMapAllocatorContext *ctx = ctx_;
109113
void *data = NULL;
110114

@@ -332,6 +336,9 @@ static void *THMapAllocator_realloc(void* ctx, void* ptr, ptrdiff_t size) {
332336
}
333337

334338
static void THMapAllocator_free(void* ctx_, void* data) {
339+
if (data == NULL)
340+
return;
341+
335342
THMapAllocatorContext *ctx = ctx_;
336343

337344
#ifdef _WIN32

0 commit comments

Comments
 (0)