diff options
author | Guilherme Iscaro <iscaro@profusion.mobi> | 2017-08-02 16:37:10 -0300 |
---|---|---|
committer | Cedric BAIL <cedric@osg.samsung.com> | 2017-08-02 16:03:20 -0700 |
commit | 48443fda8fff53138edf460532024c51dfcfa611 (patch) | |
tree | 5ba73eb209fab2f6aa561b69994f14e6e942bc06 | |
parent | c61ac48f1a3647a3010392d44781388fcae6a2a2 (diff) | |
download | efl-48443fda8fff53138edf460532024c51dfcfa611.tar.gz |
Eina_File: Avoid using munmap() on file->global_map.
When a virtualized file is created the file->global_map will not
point to a mmapped region, thus it's not safe to use munmap() during
the file cleanup. Only use munmap() if the file is backed by a FD.
Fixes: T5234.
Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
-rw-r--r-- | src/lib/eina/eina_file.c | 10 | ||||
-rw-r--r-- | src/lib/eina/eina_file_win32.c | 9 |
2 files changed, 11 insertions, 8 deletions
diff --git a/src/lib/eina/eina_file.c b/src/lib/eina/eina_file.c index 2fae7b7ad0..7e154db0a0 100644 --- a/src/lib/eina/eina_file.c +++ b/src/lib/eina/eina_file.c @@ -295,10 +295,12 @@ eina_file_real_close(Eina_File *file) free(map); } - if (!file->copied && file->global_map != MAP_FAILED) - munmap(file->global_map, file->length); - - if (file->fd != -1) close(file->fd); + if (file->fd != -1) + { + if (file->global_map != MAP_FAILED) + munmap(file->global_map, file->length); + close(file->fd); + } } static void diff --git a/src/lib/eina/eina_file_win32.c b/src/lib/eina/eina_file_win32.c index 9a5b6fd4e9..3a5831ea10 100644 --- a/src/lib/eina/eina_file_win32.c +++ b/src/lib/eina/eina_file_win32.c @@ -383,11 +383,12 @@ eina_file_real_close(Eina_File *file) free(map); } - if (file->global_map != MAP_FAILED) - UnmapViewOfFile(file->global_map); - if (file->handle != INVALID_HANDLE_VALUE) - CloseHandle(file->handle); + { + if (file->global_map != MAP_FAILED) + UnmapViewOfFile(file->global_map); + CloseHandle(file->handle); + } } static void |