diff options
author | Guilherme Iscaro <iscaro@profusion.mobi> | 2017-08-02 16:37:10 -0300 |
---|---|---|
committer | Guilherme Iscaro <iscaro@profusion.mobi> | 2017-08-02 17:06:39 -0300 |
commit | 91ea8f5b12f47aca664d93cfc027c8bd7215aac8 (patch) | |
tree | 7832767775cdc5b49af32eb0db806d34754a7f19 | |
parent | 470b48d63cfcbd08323634fa395bdbb1b93b8e2d (diff) | |
download | efl-91ea8f5b12f47aca664d93cfc027c8bd7215aac8.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.
-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 |