From 64959dcf036033c5498ac12bca7a628bc60eee7d Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Tue, 1 Apr 2008 03:49:38 +0000 Subject: Make MappedFile::map return a const correct pointer, don't leak address space on Unix platforms. llvm-svn: 49026 --- llvm/lib/System/Unix/MappedFile.inc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'llvm/lib/System/Unix') 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; -- cgit v1.2.3