summaryrefslogtreecommitdiff
path: root/apt-pkg/contrib/mmap.cc
diff options
context:
space:
mode:
Diffstat (limited to 'apt-pkg/contrib/mmap.cc')
-rw-r--r--apt-pkg/contrib/mmap.cc9
1 files changed, 5 insertions, 4 deletions
diff --git a/apt-pkg/contrib/mmap.cc b/apt-pkg/contrib/mmap.cc
index ba4482131..229b18037 100644
--- a/apt-pkg/contrib/mmap.cc
+++ b/apt-pkg/contrib/mmap.cc
@@ -175,13 +175,14 @@ DynamicMMap::DynamicMMap(unsigned long Flags,unsigned long WorkSpace) :
#ifdef _POSIX_MAPPED_FILES
// use anonymous mmap() to get the memory
Base = (unsigned char*) mmap(0, WorkSpace, PROT_READ|PROT_WRITE,
- MAP_ANONYMOUS|MAP_PRIVATE, -1, 0);
- if(Base != MAP_FAILED)
+ MAP_ANONYMOUS|MAP_PRIVATE, -1, 0);
+ if(Base == MAP_FAILED)
return;
-#endif
+#else
// fallback to a static allocated space
Base = new unsigned char[WorkSpace];
memset(Base,0,WorkSpace);
+#endif
iSize = 0;
}
/*}}}*/
@@ -193,7 +194,7 @@ DynamicMMap::~DynamicMMap()
if (Fd == 0)
{
#ifdef _POSIX_MAPPED_FILES
- munmap(Base, WorkSpace);
+ if(munmap(Base, WorkSpace) < 0)
#else
delete [] (unsigned char *)Base;
#endif