From 04250fb43ac0a4e7f616d88e3294e4271402043e Mon Sep 17 00:00:00 2001 From: Georg Hopp Date: Thu, 12 Sep 2013 10:21:19 +0100 Subject: [PATCH] only mmap a file if its size is larger than 0 bytes --- src/asset/asset.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/asset/asset.c b/src/asset/asset.c index 49605fa..1d69b64 100644 --- a/src/asset/asset.c +++ b/src/asset/asset.c @@ -96,12 +96,14 @@ assetCtor(void * _this, va_list * params) this->nmime_type = 0; } - this->data = mmap( - NULL, this->size, PROT_READ, MAP_PRIVATE, this->handle, 0); - - if (MAP_FAILED == this->data) { - close(this->handle); - return -1; + if (0 < this->size) { + this->data = mmap( + NULL, this->size, PROT_READ, MAP_PRIVATE, this->handle, 0); + + if (MAP_FAILED == this->data) { + close(this->handle); + return -1; + } } this->ref_count = 1;