Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/torch/torch7.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'lib/TH/THAllocator.c')
-rw-r--r--lib/TH/THAllocator.c7
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