diff options
author | Chris Lattner <sabre@nondot.org> | 2008-04-01 03:49:38 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2008-04-01 03:49:38 +0000 |
commit | 8ffa1ff5cb3934feffa90e656f2ccc3b3795e411 (patch) | |
tree | e806b13ec353ddcce39a37d3cfcda3bb8f43ba63 /lib/System | |
parent | 35aa79df510c0cf9ad37ec63377daaa351030772 (diff) | |
download | external_llvm-8ffa1ff5cb3934feffa90e656f2ccc3b3795e411.zip external_llvm-8ffa1ff5cb3934feffa90e656f2ccc3b3795e411.tar.gz external_llvm-8ffa1ff5cb3934feffa90e656f2ccc3b3795e411.tar.bz2 |
Make MappedFile::map return a const correct pointer, don't leak address space on Unix platforms.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@49026 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/System')
-rw-r--r-- | lib/System/Unix/MappedFile.inc | 3 | ||||
-rw-r--r-- | lib/System/Win32/MappedFile.inc | 2 |
2 files changed, 3 insertions, 2 deletions
diff --git a/lib/System/Unix/MappedFile.inc b/lib/System/Unix/MappedFile.inc index 92dc666..35efaa6 100644 --- a/lib/System/Unix/MappedFile.inc +++ b/lib/System/Unix/MappedFile.inc @@ -56,6 +56,7 @@ bool MappedFile::initialize(std::string* ErrMsg) { } void MappedFile::terminate() { + unmap(); assert(MapInfo && "MappedFile not initialized"); ::close(MapInfo->FD); delete MapInfo; @@ -70,7 +71,7 @@ void MappedFile::unmap() { BasePtr = 0; // Mark this as non-mapped. } -void* MappedFile::map(std::string* ErrMsg) { +const void* MappedFile::map(std::string* ErrMsg) { assert(MapInfo && "MappedFile not initialized"); if (isMapped()) return BasePtr; diff --git a/lib/System/Win32/MappedFile.inc b/lib/System/Win32/MappedFile.inc index 830905d..4f30f56 100644 --- a/lib/System/Win32/MappedFile.inc +++ b/lib/System/Win32/MappedFile.inc @@ -75,7 +75,7 @@ void MappedFile::unmap() { } } -void* MappedFile::map(std::string* ErrMsg) { +const void* MappedFile::map(std::string* ErrMsg) { if (!isMapped()) { MapInfo->hMapping = CreateFileMapping(MapInfo->hFile, NULL, PAGE_READONLY, 0, 0, NULL); |