forked from enlightenment/efl
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:
parent
1f82fbe14d
commit
deacfdce24
|
@ -509,7 +509,7 @@ eina_file_mmap_faulty(void *addr, long page_size)
|
||||||
|
|
||||||
eina_lock_take(&f->lock);
|
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) &&
|
if ((unsigned char *) addr < (((unsigned char *)f->global_map) + f->length) &&
|
||||||
(((unsigned char *) addr) + page_size) >= (unsigned char *) f->global_map)
|
(((unsigned char *) addr) + page_size) >= (unsigned char *) f->global_map)
|
||||||
|
|
|
@ -48,6 +48,11 @@
|
||||||
# include <Escape.h>
|
# include <Escape.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef MAP_FAILED
|
||||||
|
# undef MAP_FAILED
|
||||||
|
#endif
|
||||||
|
#define MAP_FAILED ((void *)-1)
|
||||||
|
|
||||||
Eina_Hash *_eina_file_cache = NULL;
|
Eina_Hash *_eina_file_cache = NULL;
|
||||||
Eina_Lock _eina_file_lock_cache;
|
Eina_Lock _eina_file_lock_cache;
|
||||||
|
|
||||||
|
@ -281,7 +286,7 @@ eina_file_flush(Eina_File *file, unsigned long int length)
|
||||||
Eina_List *l;
|
Eina_List *l;
|
||||||
|
|
||||||
// File size changed
|
// File size changed
|
||||||
if (file->global_map)
|
if (file->global_map != MAP_FAILED)
|
||||||
{
|
{
|
||||||
// Forget global map
|
// Forget global map
|
||||||
tmp = malloc(sizeof (Eina_File_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->dead_map = eina_list_append(file->dead_map, tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
file->global_map = NULL;
|
file->global_map = MAP_FAILED;
|
||||||
file->refcount = 0;
|
file->refcount = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue