]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/contrib/mmap.cc
update size of dynamic MMap as we write in from the outside
[apt.git] / apt-pkg / contrib / mmap.cc
index aa184b13022cb3f9ddd654ac8fbe1c565eb1bc3a..4978446d2f354f9137bbfaed7ba17ebcf395bfa6 100644 (file)
@@ -266,6 +266,8 @@ DynamicMMap::~DynamicMMap()
 {
    if (Fd == 0)
    {
+      if (Base == 0)
+        return;
 #ifdef _POSIX_MAPPED_FILES
       munmap(Base, WorkSpace);
 #else
@@ -398,6 +400,8 @@ bool DynamicMMap::Grow() {
        if (Limit != 0 && WorkSpace >= Limit)
                return _error->Error(_("Unable to increase the size of the MMap as the "
                                       "limit of %lu bytes is already reached."), Limit);
+       if (GrowFactor <= 0)
+               return _error->Error(_("Unable to increase size of the MMap as automatic growing is disabled by user."));
 
        unsigned long const newSize = WorkSpace + GrowFactor;