raster pushed a commit to branch v-1.26.0. http://git.enlightenment.org/core/efl.git/commit/?id=f39af23cee8ea0c58a23e65bbd9e30d630d3f70c
commit f39af23cee8ea0c58a23e65bbd9e30d630d3f70c Author: Carsten Haitzler <[email protected]> Date: Tue Jan 4 09:44:20 2022 +0000 eet - fix seg when doing unusual things with eet write then read if you write and read0-back before writign out (non-sensical to do as you would write out in full and close and then open file and read separately) the dictionary will be empty. fill it in these paths. fixes needed resulting from optimizations in 1.26.0 @fix --- src/lib/eet/Eet_private.h | 2 ++ src/lib/eet/eet_data.c | 16 ++++++++++++++++ src/lib/eet/eet_dictionary.c | 16 +++++++++------- 3 files changed, 27 insertions(+), 7 deletions(-) diff --git a/src/lib/eet/Eet_private.h b/src/lib/eet/Eet_private.h index 8b85a9377f..f517dc5071 100644 --- a/src/lib/eet/Eet_private.h +++ b/src/lib/eet/Eet_private.h @@ -289,6 +289,8 @@ int eet_dictionary_string_get_hash(Eet_Dictionary *ed, int index); +void +eet_dictionary_write_prepare_unlocked(Eet_Dictionary *ed); void eet_dictionary_write_prepare(Eet_Dictionary *ed); diff --git a/src/lib/eet/eet_data.c b/src/lib/eet/eet_data.c index 3ed40b7c9b..96015586f4 100644 --- a/src/lib/eet/eet_data.c +++ b/src/lib/eet/eet_data.c @@ -3481,6 +3481,8 @@ _eet_data_descriptor_decode(Eet_Free_Context *context, Eet_Data_Chunk chnk; Eina_Bool need_free = EINA_FALSE; + if (ed) eet_dictionary_write_prepare_unlocked((Eet_Dictionary *)ed); + if (_eet_data_words_bigendian == -1) { unsigned long int v; @@ -3732,6 +3734,8 @@ eet_data_get_list(Eet_Free_Context *context, list = *ptr; data_ret = NULL; + if (ed) eet_dictionary_write_prepare_unlocked((Eet_Dictionary *)ed); + if (IS_POINTER_TYPE(type)) POINTER_TYPE_DECODE(context, ed, @@ -3797,6 +3801,8 @@ eet_data_get_hash(Eet_Free_Context *context, ptr = (void **)data; hash = *ptr; + if (ed) eet_dictionary_write_prepare_unlocked((Eet_Dictionary *)ed); + /* Read key */ ret = eet_data_get_type(ed, EET_T_STRING, @@ -3899,6 +3905,8 @@ eet_data_get_array(Eet_Free_Context *context, EET_ASSERT(!((type > EET_T_UNKNOW) && (type < EET_T_STRING)), return 0); + if (ed) eet_dictionary_write_prepare_unlocked((Eet_Dictionary *)ed); + ptr = data; /* read the number of elements */ ret = eet_data_get_type(ed, @@ -4117,6 +4125,8 @@ eet_data_get_union(Eet_Free_Context *context, int ret = 0; int i; + if (ed) eet_dictionary_write_prepare_unlocked((Eet_Dictionary *)ed); + /* Read type */ ret = eet_data_get_type(ed, EET_T_STRING, @@ -4344,6 +4354,8 @@ eet_data_get_variant(Eet_Free_Context *context, int ret = 0; int i; + if (ed) eet_dictionary_write_prepare_unlocked((Eet_Dictionary *)ed); + /* Read type */ ret = eet_data_get_type(ed, EET_T_STRING, @@ -4532,6 +4544,8 @@ eet_data_get_unknown(Eet_Free_Context *context, int ret; void *data_ret; + if (ed) eet_dictionary_write_prepare_unlocked((Eet_Dictionary *)ed); + if (IS_SIMPLE_TYPE(type)) { unsigned long long dd[128]; @@ -4830,6 +4844,8 @@ eet_data_dump_cipher(Eet_File *ef, ed = eet_dictionary_get(ef); + if (ed) eet_dictionary_write_prepare((Eet_Dictionary *)ed); + if (!cipher_key) data = eet_read_direct(ef, name, &size); diff --git a/src/lib/eet/eet_dictionary.c b/src/lib/eet/eet_dictionary.c index ea54b118ad..4413a6d690 100644 --- a/src/lib/eet/eet_dictionary.c +++ b/src/lib/eet/eet_dictionary.c @@ -95,14 +95,9 @@ on_error: } void -eet_dictionary_write_prepare(Eet_Dictionary *ed) +eet_dictionary_write_prepare_unlocked(Eet_Dictionary *ed) { - eina_rwlock_take_write(&ed->rwlock); - if (!ed->add_hash) - { - eina_rwlock_release(&ed->rwlock); - return; - } + if (!ed->add_hash) return; ed->total = ed->count; @@ -113,6 +108,13 @@ eet_dictionary_write_prepare(Eet_Dictionary *ed) eina_hash_foreach(ed->add_hash, _eet_dictionary_write_prepare_hash_cb, ed); eina_hash_free(ed->add_hash); ed->add_hash = NULL; +} + +void +eet_dictionary_write_prepare(Eet_Dictionary *ed) +{ + eina_rwlock_take_write(&ed->rwlock); + eet_dictionary_write_prepare_unlocked(ed); eina_rwlock_release(&ed->rwlock); } --
