[PATCH] MemoryBuffer: don't force mmap when stat fails

Alp Toker alp at nuanti.com
Wed May 7 03:43:28 PDT 2014


Fixes error handling introduced in r127426 that could result in mmapped 
MemoryBuffers not having null termination.

Alp.

-- 
http://www.nuanti.com
the browser experts

-------------- next part --------------
commit 942f56d23382d44b9c92294a2c4a1b50d845dc63
Author: Alp Toker <alp at nuanti.com>
Date:   Wed May 7 08:59:16 2014 +0100

    MemoryBuffer: don't force mmap when stat fails
    
    Fix error handling introduced in r127426 that could result in MemoryBuffers not
    having null termination.

diff --git a/lib/Support/MemoryBuffer.cpp b/lib/Support/MemoryBuffer.cpp
index 90945ab..11c0e3d 100644
--- a/lib/Support/MemoryBuffer.cpp
+++ b/lib/Support/MemoryBuffer.cpp
@@ -328,9 +328,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();
   }
 


More information about the llvm-commits mailing list