aboutsummaryrefslogtreecommitdiff
path: root/src/mmap.c
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org>2016-12-21 08:17:57 +0200
committerSergey Poznyakoff <gray@gnu.org>2016-12-21 08:17:57 +0200
commit9ca58064e8a10546004c9a376a63105698a72d3c (patch)
treee54bdf3bcd8fe1e7f2fb57d6eca06605e9c3b47e /src/mmap.c
parent46aeea15845301873e1e7f7ed6d609a9631c2486 (diff)
downloadgdbm-9ca58064e8a10546004c9a376a63105698a72d3c.tar.gz
gdbm-9ca58064e8a10546004c9a376a63105698a72d3c.tar.bz2
Minor fix
* src/mmap.c (_gdbm_internal_remap): Avoid munmapping NULL pointer. Make sure mapped_region isn't a dangling pointer.
Diffstat (limited to 'src/mmap.c')
-rw-r--r--src/mmap.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/mmap.c b/src/mmap.c
index 7ec5fe3..555e82f 100644
--- a/src/mmap.c
+++ b/src/mmap.c
@@ -82,7 +82,11 @@ _gdbm_internal_remap (GDBM_FILE dbf, size_t size)
int flags = PROT_READ;
size_t page_size = sysconf (_SC_PAGESIZE);
- munmap (dbf->mapped_region, dbf->mapped_size);
+ if (dbf->mapped_region)
+ {
+ munmap (dbf->mapped_region, dbf->mapped_size);
+ dbf->mapped_region = NULL;
+ }
dbf->mapped_size = size;
if (size == 0)

Return to:

Send suggestions and report system problems to the System administrator.