diff options
author | Soumith Chintala <soumith@gmail.com> | 2017-07-13 09:54:17 +0300 |
---|---|---|
committer | Soumith Chintala <soumith@gmail.com> | 2017-07-14 09:54:39 +0300 |
commit | 6a35cd9a7073ec16596afb7116ecef5802844f30 (patch) | |
tree | 7311a18a57199b95d9f861534d3abcd8bd3b7478 | |
parent | 2186e414ad8fc4dfc9f2ed090c0bf8a0e1946e62 (diff) |
fix empty Tensor mmap
-rw-r--r-- | lib/TH/THAllocator.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/TH/THAllocator.c b/lib/TH/THAllocator.c index 51ac69b..e69b3cc 100644 --- a/lib/TH/THAllocator.c +++ b/lib/TH/THAllocator.c @@ -105,6 +105,10 @@ void THMapAllocatorContext_free(THMapAllocatorContext *ctx) static void *_map_alloc(void* ctx_, ptrdiff_t size) { + if (size == 0) { + return NULL; + } + THMapAllocatorContext *ctx = ctx_; void *data = NULL; @@ -332,6 +336,9 @@ static void *THMapAllocator_realloc(void* ctx, void* ptr, ptrdiff_t size) { } static void THMapAllocator_free(void* ctx_, void* data) { + if (data == NULL) + return; + THMapAllocatorContext *ctx = ctx_; #ifdef _WIN32 |