summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2013-08-22 21:13:38 +0900
committerCedric Bail <cedric.bail@samsung.com>2013-08-27 17:31:12 +0900
commitdeacfdce24871b744618ac598c2a54774291e620 (patch)
treec9442b96fbf472245050c97c1c012cd4f62ee390
parent1f82fbe14d2ac5a2437e7905065974033920d139 (diff)
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.
Diffstat (limited to '')
-rw-r--r--src/lib/eina/eina_file.c2
-rw-r--r--src/lib/eina/eina_file_common.c9
2 files changed, 8 insertions, 3 deletions
diff --git a/src/lib/eina/eina_file.c b/src/lib/eina/eina_file.c
index ae68287ccd..dd2d1647a8 100644
--- a/src/lib/eina/eina_file.c
+++ b/src/lib/eina/eina_file.c
@@ -509,7 +509,7 @@ eina_file_mmap_faulty(void *addr, long page_size)
509 509
510 eina_lock_take(&f->lock); 510 eina_lock_take(&f->lock);
511 511
512 if (f->global_map) 512 if (f->global_map != MAP_FAILED)
513 { 513 {
514 if ((unsigned char *) addr < (((unsigned char *)f->global_map) + f->length) && 514 if ((unsigned char *) addr < (((unsigned char *)f->global_map) + f->length) &&
515 (((unsigned char *) addr) + page_size) >= (unsigned char *) f->global_map) 515 (((unsigned char *) addr) + page_size) >= (unsigned char *) f->global_map)
diff --git a/src/lib/eina/eina_file_common.c b/src/lib/eina/eina_file_common.c
index a154b1efb8..5c59b86d26 100644
--- a/src/lib/eina/eina_file_common.c
+++ b/src/lib/eina/eina_file_common.c
@@ -48,6 +48,11 @@
48# include <Escape.h> 48# include <Escape.h>
49#endif 49#endif
50 50
51#ifdef MAP_FAILED
52# undef MAP_FAILED
53#endif
54#define MAP_FAILED ((void *)-1)
55
51Eina_Hash *_eina_file_cache = NULL; 56Eina_Hash *_eina_file_cache = NULL;
52Eina_Lock _eina_file_lock_cache; 57Eina_Lock _eina_file_lock_cache;
53 58
@@ -281,7 +286,7 @@ eina_file_flush(Eina_File *file, unsigned long int length)
281 Eina_List *l; 286 Eina_List *l;
282 287
283 // File size changed 288 // File size changed
284 if (file->global_map) 289 if (file->global_map != MAP_FAILED)
285 { 290 {
286 // Forget global map 291 // Forget global map
287 tmp = malloc(sizeof (Eina_File_Map)); 292 tmp = malloc(sizeof (Eina_File_Map));
@@ -295,7 +300,7 @@ eina_file_flush(Eina_File *file, unsigned long int length)
295 file->dead_map = eina_list_append(file->dead_map, tmp); 300 file->dead_map = eina_list_append(file->dead_map, tmp);
296 } 301 }
297 302
298 file->global_map = NULL; 303 file->global_map = MAP_FAILED;
299 file->refcount = 0; 304 file->refcount = 0;
300 } 305 }
301 306