[compiler-rt] r190359 - Don't allow a NULL-length file. Try to revert to the buffered version.

Bill Wendling isanbard at gmail.com
Mon Sep 9 15:25:46 PDT 2013


Author: void
Date: Mon Sep  9 17:25:46 2013
New Revision: 190359

URL: http://llvm.org/viewvc/llvm-project?rev=190359&view=rev
Log:
Don't allow a NULL-length file. Try to revert to the buffered version.

Modified:
    compiler-rt/trunk/lib/profile/GCDAProfiling.c

Modified: compiler-rt/trunk/lib/profile/GCDAProfiling.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/profile/GCDAProfiling.c?rev=190359&r1=190358&r2=190359&view=diff
==============================================================================
--- compiler-rt/trunk/lib/profile/GCDAProfiling.c (original)
+++ compiler-rt/trunk/lib/profile/GCDAProfiling.c Mon Sep  9 17:25:46 2013
@@ -206,6 +206,11 @@ static int map_file() {
   fseek(output_file, 0L, SEEK_END);
   file_size = ftell(output_file);
 
+  /* A size of 0 is invaild to `mmap'. Return a fail here, but don't issue an
+   * error message because it should "just work" for the user. */
+  if (file_size == 0)
+    return -1;
+
   write_buffer = mmap(0, file_size, PROT_READ | PROT_WRITE,
                       MAP_FILE | MAP_SHARED, fd, 0);
   if (write_buffer == (void *)-1) {





More information about the llvm-commits mailing list