summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@osg.samsung.com>2018-02-22 11:18:55 +0100
committerDaniel Kolesa <d.kolesa@osg.samsung.com>2018-02-22 11:19:23 +0100
commit26f0c56fafea8b46bbb425c3a0f808c1881fc08f (patch)
treeb93cdf92f7bf9d8c8be23b606d4fc7df58679722
parent665b88204cae45a9aae7c1bdcdd4fbf1e2ac6fcb (diff)
eolian: fix eina hash usage so it doesn't consume all your memory
This makes sure items are checked before being added, so that eina hash doesn't get confused, add each item thousands of times and run out of memory.
-rw-r--r--src/lib/eolian/eo_parser.c2
-rw-r--r--src/lib/eolian/eolian_database.c9
2 files changed, 8 insertions, 3 deletions
diff --git a/src/lib/eolian/eo_parser.c b/src/lib/eolian/eo_parser.c
index 4a4757a949..56c6a4bfa3 100644
--- a/src/lib/eolian/eo_parser.c
+++ b/src/lib/eolian/eo_parser.c
@@ -2256,7 +2256,7 @@ eo_parser_database_fill(Eolian_Unit *parent, const char *filename, Eina_Bool eot
2256 2256
2257 if (ret) 2257 if (ret)
2258 { 2258 {
2259 if (parent != ret) 2259 if ((parent != ret) && !eina_hash_find(parent->children, filename))
2260 eina_hash_add(parent->children, filename, ret); 2260 eina_hash_add(parent->children, filename, ret);
2261 return ret; 2261 return ret;
2262 } 2262 }
diff --git a/src/lib/eolian/eolian_database.c b/src/lib/eolian/eolian_database.c
index b932cdaa7e..514d4bf63a 100644
--- a/src/lib/eolian/eolian_database.c
+++ b/src/lib/eolian/eolian_database.c
@@ -706,8 +706,12 @@ static Eina_Bool
706_merge_unit_cb(const Eina_Hash *hash EINA_UNUSED, 706_merge_unit_cb(const Eina_Hash *hash EINA_UNUSED,
707 const void *key, void *data, void *fdata) 707 const void *key, void *data, void *fdata)
708{ 708{
709 if (eina_hash_add((Eina_Hash *)fdata, key, data)) 709 Eina_Hash *dest = fdata;
710 eolian_object_ref((Eolian_Object *)data); 710 if (!eina_hash_find(dest, key))
711 {
712 eina_hash_add(dest, key, data);
713 eolian_object_ref((Eolian_Object *)data);
714 }
711 return EINA_TRUE; 715 return EINA_TRUE;
712} 716}
713 717
@@ -744,6 +748,7 @@ _merge_units_cb(const Eina_Hash *hash EINA_UNUSED,
744 return EINA_TRUE; 748 return EINA_TRUE;
745} 749}
746 750
751
747static void 752static void
748_merge_units(Eolian_Unit *unit) 753_merge_units(Eolian_Unit *unit)
749{ 754{