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 | 64959dcf036033c5498ac12bca7a628bc60eee7d (patch) | |
tree | 904bb834bf8afccfd4c14e32f47f9a8a4b17bf53 /llvm/lib/System/Unix | |
parent | bcfa564759423f40be305124bb6ad88b531f69ae (diff) | |
download | bcm5719-llvm-64959dcf036033c5498ac12bca7a628bc60eee7d.tar.gz bcm5719-llvm-64959dcf036033c5498ac12bca7a628bc60eee7d.zip |
Make MappedFile::map return a const correct pointer, don't leak address space on Unix platforms.
llvm-svn: 49026
Diffstat (limited to 'llvm/lib/System/Unix')
-rw-r--r-- | llvm/lib/System/Unix/MappedFile.inc | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/llvm/lib/System/Unix/MappedFile.inc b/llvm/lib/System/Unix/MappedFile.inc index 92dc6660439..35efaa6fcb9 100644 --- a/llvm/lib/System/Unix/MappedFile.inc +++ b/llvm/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; |