eina_file: make sure we use a stringshare when virtualized.
authorAl Poole <netstar@gmail.com>
Thu, 30 Nov 2017 13:57:25 +0000 (13:57 +0000)
committerAl Poole <netstar@gmail.com>
Thu, 30 Nov 2017 13:57:25 +0000 (13:57 +0000)
As the filename is now a stringshare, also make sure virtual
files use stringshares for the filename! Also when unmapping
we still need to test whether it is copied or not as unmap
will break on less tolerant architectures.

@fix T6449

src/lib/eina/eina_file.c
src/lib/eina/eina_file_common.c

index d56612f..bf02410 100644 (file)
@@ -300,7 +300,7 @@ eina_file_real_close(Eina_File *file)
 
    if (file->fd != -1)
      {
-        if (file->global_map != MAP_FAILED)
+        if (!file->copied && file->global_map != MAP_FAILED)
           munmap(file->global_map, file->length);
         close(file->fd);
      }
index edebaed..1c53226 100644 (file)
@@ -422,9 +422,9 @@ eina_file_virtualize(const char *virtual_name, const void *data, unsigned long l
    EINA_MAGIC_SET(file, EINA_FILE_MAGIC);
    file->filename = (char *)(file + 1);
    if (virtual_name)
-     strcpy((char *)file->filename, virtual_name);
+     file->filename = eina_stringshare_add(virtual_name);
    else
-     sprintf((char *)file->filename, tmpname, ti);
+     file->filename = eina_stringshare_printf(tmpname, ti);
 
    eina_lock_recursive_new(&file->lock);
    file->mtime = ti / 1000;