summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuilherme Iscaro <iscaro@profusion.mobi>2017-08-02 16:37:10 -0300
committerCedric BAIL <cedric@osg.samsung.com>2017-08-02 16:03:20 -0700
commit48443fda8fff53138edf460532024c51dfcfa611 (patch)
tree5ba73eb209fab2f6aa561b69994f14e6e942bc06
parentc61ac48f1a3647a3010392d44781388fcae6a2a2 (diff)
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.c10
-rw-r--r--src/lib/eina/eina_file_win32.c9
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)
295 free(map); 295 free(map);
296 } 296 }
297 297
298 if (!file->copied && file->global_map != MAP_FAILED) 298 if (file->fd != -1)
299 munmap(file->global_map, file->length); 299 {
300 300 if (file->global_map != MAP_FAILED)
301 if (file->fd != -1) close(file->fd); 301 munmap(file->global_map, file->length);
302 close(file->fd);
303 }
302} 304}
303 305
304static void 306static 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)
383 free(map); 383 free(map);
384 } 384 }
385 385
386 if (file->global_map != MAP_FAILED)
387 UnmapViewOfFile(file->global_map);
388
389 if (file->handle != INVALID_HANDLE_VALUE) 386 if (file->handle != INVALID_HANDLE_VALUE)
390 CloseHandle(file->handle); 387 {
388 if (file->global_map != MAP_FAILED)
389 UnmapViewOfFile(file->global_map);
390 CloseHandle(file->handle);
391 }
391} 392}
392 393
393static void 394static void