summaryrefslogtreecommitdiff
path: root/lib/System/Unix
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2008-04-01 03:49:38 +0000
committerChris Lattner <sabre@nondot.org>2008-04-01 03:49:38 +0000
commit23ffec82584568b1d789c8697486ad062cfd6711 (patch)
treee806b13ec353ddcce39a37d3cfcda3bb8f43ba63 /lib/System/Unix
parent37db5d67f92504226c17cfbf98c07c7bbe3afc3b (diff)
downloadllvm-23ffec82584568b1d789c8697486ad062cfd6711.tar.gz
llvm-23ffec82584568b1d789c8697486ad062cfd6711.tar.bz2
llvm-23ffec82584568b1d789c8697486ad062cfd6711.tar.xz
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/Unix')
-rw-r--r--lib/System/Unix/MappedFile.inc3
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/System/Unix/MappedFile.inc b/lib/System/Unix/MappedFile.inc
index 92dc666043..35efaa6fcb 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;