summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>2022-01-04 09:44:20 +0000
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2022-01-04 09:44:20 +0000
commit34a36b49e1dae0ddf874d008410fc9e7d0186928 (patch)
treee252ada9624295e7551b6a9eed74d3541fbbcdee
parent29029bc7810e90b078b7fb54dec9ac75af1bf3f9 (diff)
downloadefl-34a36b49e1dae0ddf874d008410fc9e7d0186928.tar.gz
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
-rw-r--r--src/lib/eet/Eet_private.h2
-rw-r--r--src/lib/eet/eet_data.c16
-rw-r--r--src/lib/eet/eet_dictionary.c16
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
@@ -290,6 +290,8 @@ 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);
int
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);
}