jpeg pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=9aeaef55c4f6791feaddbd6be9c6dbc6e3e0c087

commit 9aeaef55c4f6791feaddbd6be9c6dbc6e3e0c087
Author: Al Poole <[email protected]>
Date:   Fri Jul 7 11:19:31 2017 +0900

    eina_file: fix unmap of unmapped region when Eina_File has copied data and 
not a map;
    
    Summary:
    This was causing problems on non-Linux architectures as 
eina_file_real_close unmapped not mapped data. Added a "copied" flag to 
Eina_File which is set on eina_file_virtualize (on copied data), and tested for 
when eina_file_real_close does the unmap. I'm surprised Linux allowed this. 
Certainly all of the BSDs crashed with the previous behaviour.
    
    @fix T5479
    
    Test Plan: Example inlcude Rage and Enlightenment Thumb on BSD systems 
which use eina_file_virtualize with emotion to obtain album artwork.
    
    Reviewers: raster, cedric, jpeg
    
    Reviewed By: jpeg
    
    Maniphest Tasks: T5479
    
    Differential Revision: https://phab.enlightenment.org/D5006
---
 src/lib/eina/eina_file.c        | 2 +-
 src/lib/eina/eina_file_common.c | 1 +
 src/lib/eina/eina_file_common.h | 1 +
 3 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/lib/eina/eina_file.c b/src/lib/eina/eina_file.c
index 4a0c7823b5..2fae7b7ad0 100644
--- a/src/lib/eina/eina_file.c
+++ b/src/lib/eina/eina_file.c
@@ -295,7 +295,7 @@ eina_file_real_close(Eina_File *file)
         free(map);
      }
 
-   if (file->global_map != MAP_FAILED)
+   if (!file->copied && file->global_map != MAP_FAILED)
      munmap(file->global_map, file->length);
 
    if (file->fd != -1) close(file->fd);
diff --git a/src/lib/eina/eina_file_common.c b/src/lib/eina/eina_file_common.c
index 1008a5f224..e0d164a2c2 100644
--- a/src/lib/eina/eina_file_common.c
+++ b/src/lib/eina/eina_file_common.c
@@ -448,6 +448,7 @@ eina_file_virtualize(const char *virtual_name, const void 
*data, unsigned long l
 
    if (copy)
      {
+        file->copied = EINA_TRUE;
         file->global_map = ((char *)file) + head_padded;
         memcpy((char *)file->global_map, data, length);
      }
diff --git a/src/lib/eina/eina_file_common.h b/src/lib/eina/eina_file_common.h
index 6fcecb2fa8..0502029df6 100644
--- a/src/lib/eina/eina_file_common.h
+++ b/src/lib/eina/eina_file_common.h
@@ -102,6 +102,7 @@ struct _Eina_File
    Eina_Bool delete_me : 1;      /**< Indicates that this file should be 
deleted */
    Eina_Bool global_faulty : 1;  /**< Indicates whether #global_map is bad */
    Eina_Bool virtual : 1;        /**< Indicates that this is a virtual file */
+   Eina_Bool copied : 1;         /**< Indicates whether this file has copied 
data */
 };
 
 /**

-- 


Reply via email to