diff options
author | Bill Wendling <isanbard@gmail.com> | 2013-09-09 22:25:46 +0000 |
---|---|---|
committer | Bill Wendling <isanbard@gmail.com> | 2013-09-09 22:25:46 +0000 |
commit | 7ab94ea0d5182da0e0ed1dc2c3cf40beccbf25b9 (patch) | |
tree | db395f1ff05a6952c19e1c06ab1e78e395e8c790 /lib/profile | |
parent | bb22942b91bf0855da4a9da132c77f325b187b84 (diff) | |
download | compiler-rt-7ab94ea0d5182da0e0ed1dc2c3cf40beccbf25b9.tar.gz |
Don't allow a NULL-length file. Try to revert to the buffered version.
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@190359 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/profile')
-rw-r--r-- | lib/profile/GCDAProfiling.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/profile/GCDAProfiling.c b/lib/profile/GCDAProfiling.c index ea62e794a..f80e06248 100644 --- a/lib/profile/GCDAProfiling.c +++ b/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) { |