From edd33cfbb6fa6661aa3063bea62a386828292a77 Mon Sep 17 00:00:00 2001
From: Pedro Gonnet <gonnet@google.com>
Date: Wed, 20 Dec 2017 21:36:35 +0100
Subject: [PATCH] unmap all the bytes.

---
 src/dump.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/dump.c b/src/dump.c
index de5c5afb18..ba50b517a7 100644
--- a/src/dump.c
+++ b/src/dump.c
@@ -61,13 +61,13 @@ void dump_ensure(struct dump *d, size_t size) {
   if (d->size - d->count > size) return;
 
   /* Unmap the current data. */
-  size_t trunc_count = d->count & d->page_mask;
-  if (munmap(d->data, trunc_count > 0 ? trunc_count : 1) != 0) {
-    error("Failed to unmap %zi bytes of dump data (%s).", trunc_count,
+  if (munmap(d->data, d->size) != 0) {
+    error("Failed to unmap %zi bytes of dump data (%s).", d->size,
           strerror(errno));
   }
 
   /* Update the size and count. */
+  const size_t trunc_count = d->count & d->page_mask;
   d->file_offset += trunc_count;
   d->count -= trunc_count;
   d->size = (size * dump_grow_ensure_factor + ~d->page_mask) & d->page_mask;
-- 
GitLab