From 796f8789f80568861b747265998f31fa83091915 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Mon, 11 Sep 2017 00:48:17 +0200 Subject: storeio: Avoid calling mmap with zero size * storeio/dev.c (dev_open): When store is zero-sized, set buf to NULL instead of calling mmap(). --- storeio/dev.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'storeio') diff --git a/storeio/dev.c b/storeio/dev.c index 78e0a177..8bdfa111 100644 --- a/storeio/dev.c +++ b/storeio/dev.c @@ -161,8 +161,11 @@ dev_open (struct dev *dev) to support this. */ store_set_flags (dev->store, STORE_INACTIVE); - dev->buf = mmap (0, dev->store->block_size, PROT_READ|PROT_WRITE, - MAP_ANON, 0, 0); + if (! dev->store->block_size) + dev->buf = NULL; + else + dev->buf = mmap (0, dev->store->block_size, PROT_READ|PROT_WRITE, + MAP_ANON, 0, 0); if (dev->buf == MAP_FAILED) { store_free (dev->store); -- cgit v1.2.3