summaryrefslogtreecommitdiff
path: root/src/lib/edje
diff options
context:
space:
mode:
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>2017-02-03 14:39:57 +0900
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2017-02-03 14:39:57 +0900
commit9c3df02c4183974013a7d515740911341414f708 (patch)
treecbd11fc3047eb0480d83bc5ec957b0db112f3e2b /src/lib/edje
parente94967da72488952854d4617bb67f0ee74c810f9 (diff)
edje - fix crash on loading ancient edje files
ancient edje files dont put hash strings in the file dictionary but instead inline and thus the strings cannot be direct added... silly ancient files. this is a horrible ugly workaround this but there isn't really anything better than trying to detect such files (which dont seem to have an older version in them i can find?) so detect by pointer address and mapping the file. this fixes T5138 @fix
Diffstat (limited to 'src/lib/edje')
-rw-r--r--src/lib/edje/edje_cache.c22
-rw-r--r--src/lib/edje/edje_data.c11
2 files changed, 32 insertions, 1 deletions
diff --git a/src/lib/edje/edje_cache.c b/src/lib/edje/edje_cache.c
index 0199f4d40b..c38e9433eb 100644
--- a/src/lib/edje/edje_cache.c
+++ b/src/lib/edje/edje_cache.c
@@ -278,6 +278,12 @@ _edje_file_coll_open(Edje_File *edf, const char *coll)
278 return edc; 278 return edc;
279} 279}
280 280
281// XXX: this is not pretty. some oooooold edje files do not store strings
282// in their dictionary for hashes. this works around crashes loading such
283// files
284extern size_t _edje_data_string_mapping_size;
285extern void *_edje_data_string_mapping;
286
281static Edje_File * 287static Edje_File *
282_edje_file_open(const Eina_File *f, int *error_ret, time_t mtime, Eina_Bool coll) 288_edje_file_open(const Eina_File *f, int *error_ret, time_t mtime, Eina_Bool coll)
283{ 289{
@@ -289,6 +295,8 @@ _edje_file_open(const Eina_File *f, int *error_ret, time_t mtime, Eina_Bool coll
289 Eina_List *l, *ll; 295 Eina_List *l, *ll;
290 Eet_File *ef; 296 Eet_File *ef;
291 char *name; 297 char *name;
298 void *mapping;
299 size_t mapping_size;
292 300
293 ef = eet_mmap(f); 301 ef = eet_mmap(f);
294 if (!ef) 302 if (!ef)
@@ -296,7 +304,21 @@ _edje_file_open(const Eina_File *f, int *error_ret, time_t mtime, Eina_Bool coll
296 *error_ret = EDJE_LOAD_ERROR_UNKNOWN_FORMAT; 304 *error_ret = EDJE_LOAD_ERROR_UNKNOWN_FORMAT;
297 return NULL; 305 return NULL;
298 } 306 }
307 // XXX: ancient edje file workaround
308 mapping = eina_file_map_all((Eina_File *)f, EINA_FILE_SEQUENTIAL);
309 if (mapping)
310 {
311 mapping_size = eina_file_size_get(f);
312 _edje_data_string_mapping = mapping;
313 _edje_data_string_mapping_size = mapping_size;
314 }
299 edf = eet_data_read(ef, _edje_edd_edje_file, "edje/file"); 315 edf = eet_data_read(ef, _edje_edd_edje_file, "edje/file");
316 // XXX: ancient edje file workaround
317 if (mapping)
318 {
319 eina_file_map_free((Eina_File *)f, mapping);
320 _edje_data_string_mapping = NULL;
321 }
300 if (!edf) 322 if (!edf)
301 { 323 {
302 *error_ret = EDJE_LOAD_ERROR_CORRUPT_FILE; 324 *error_ret = EDJE_LOAD_ERROR_CORRUPT_FILE;
diff --git a/src/lib/edje/edje_data.c b/src/lib/edje/edje_data.c
index df21571740..e6d2fbb081 100644
--- a/src/lib/edje/edje_data.c
+++ b/src/lib/edje/edje_data.c
@@ -639,6 +639,9 @@ _edje_description_variant_type_set(const char *type, void *data, Eina_Bool unkno
639 return EINA_FALSE; 639 return EINA_FALSE;
640} 640}
641 641
642size_t _edje_data_string_mapping_size = 0;
643void *_edje_data_string_mapping = NULL;
644
642static Eina_Hash * 645static Eina_Hash *
643_edje_eina_hash_add_alloc(Eina_Hash *hash, 646_edje_eina_hash_add_alloc(Eina_Hash *hash,
644 const char *key, 647 const char *key,
@@ -650,7 +653,13 @@ _edje_eina_hash_add_alloc(Eina_Hash *hash,
650 if (!hash) 653 if (!hash)
651 return NULL; 654 return NULL;
652 655
653 eina_hash_direct_add(hash, key, data); 656 // XXX: ancient edje file workaround
657 if ((_edje_data_string_mapping) &&
658 ((key >= (char *)_edje_data_string_mapping) &&
659 (key < ((char *)_edje_data_string_mapping + _edje_data_string_mapping_size))))
660 eina_hash_direct_add(hash, key, data);
661 else
662 eina_hash_add(hash, key, data);
654 return hash; 663 return hash;
655} 664}
656 665