From ece806e2955bff61ef60295ea36b920143493992 Mon Sep 17 00:00:00 2001 From: Alp Toker Date: Fri, 9 May 2014 08:57:32 +0000 Subject: [PATCH] MemoryBuffer: don't force mmap when stat fails Fix error handling introduced in r127426 that could result in MemoryBuffers not having null termination. llvm-svn: 208396 --- lib/Support/MemoryBuffer.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/Support/MemoryBuffer.cpp b/lib/Support/MemoryBuffer.cpp index f95383dfb29..26c3a2ebd26 100644 --- a/lib/Support/MemoryBuffer.cpp +++ b/lib/Support/MemoryBuffer.cpp @@ -320,9 +320,8 @@ static bool shouldUseMmap(int FD, // RequiresNullTerminator = false and MapSize != -1. if (FileSize == size_t(-1)) { sys::fs::file_status Status; - error_code EC = sys::fs::status(FD, Status); - if (EC) - return EC; + if (sys::fs::status(FD, Status)) + return false; FileSize = Status.getSize(); }