summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib
diff options
context:
space:
mode:
authorBill Wendling <isanbard@gmail.com>2013-09-09 22:25:46 +0000
committerBill Wendling <isanbard@gmail.com>2013-09-09 22:25:46 +0000
commit97c22c3c92dfa319de85a121de96d04ed3924736 (patch)
treef081269dfc70ca49446e76fb658cf24afa587720 /compiler-rt/lib
parent170a5f29831d5d8e8897b3815edee19a362ae78d (diff)
downloadbcm5719-llvm-97c22c3c92dfa319de85a121de96d04ed3924736.tar.gz
bcm5719-llvm-97c22c3c92dfa319de85a121de96d04ed3924736.zip
Don't allow a NULL-length file. Try to revert to the buffered version.
llvm-svn: 190359
Diffstat (limited to 'compiler-rt/lib')
-rw-r--r--compiler-rt/lib/profile/GCDAProfiling.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/compiler-rt/lib/profile/GCDAProfiling.c b/compiler-rt/lib/profile/GCDAProfiling.c
index ea62e794a51..f80e062485e 100644
--- a/compiler-rt/lib/profile/GCDAProfiling.c
+++ b/compiler-rt/lib/profile/GCDAProfiling.c
@@ -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) {
OpenPOWER on IntegriCloud