eina: Fix invalid check on Eina_File::global_map

global_map is set to MAP_FAILED in case of error after mmap.
So, it is initialized to MAP_FAILED and considered valid
otherwise.

So, we don't want to set the map to NULL or even check again NULL.
This commit is contained in:
Jean-Philippe Andre 2013-08-22 21:13:38 +09:00 committed by Cedric Bail
parent 1f82fbe14d
commit deacfdce24
2 changed files with 8 additions and 3 deletions

View File

@ -509,7 +509,7 @@ eina_file_mmap_faulty(void *addr, long page_size)
eina_lock_take(&f->lock);
if (f->global_map)
if (f->global_map != MAP_FAILED)
{
if ((unsigned char *) addr < (((unsigned char *)f->global_map) + f->length) &&
(((unsigned char *) addr) + page_size) >= (unsigned char *) f->global_map)

View File

@ -48,6 +48,11 @@
# include <Escape.h>
#endif
#ifdef MAP_FAILED
# undef MAP_FAILED
#endif
#define MAP_FAILED ((void *)-1)
Eina_Hash *_eina_file_cache = NULL;
Eina_Lock _eina_file_lock_cache;
@ -281,7 +286,7 @@ eina_file_flush(Eina_File *file, unsigned long int length)
Eina_List *l;
// File size changed
if (file->global_map)
if (file->global_map != MAP_FAILED)
{
// Forget global map
tmp = malloc(sizeof (Eina_File_Map));
@ -295,7 +300,7 @@ eina_file_flush(Eina_File *file, unsigned long int length)
file->dead_map = eina_list_append(file->dead_map, tmp);
}
file->global_map = NULL;
file->global_map = MAP_FAILED;
file->refcount = 0;
}