From 64a5f5751c66ae99a5391f7574315eccbefe8cf9 Mon Sep 17 00:00:00 2001 From: Hermet Park Date: Tue, 22 Jan 2019 14:10:34 +0900 Subject: [PATCH] evas vg: fix a memory leak. if a vector file data is not sharable, it must close the file immediately when the instance is destroyed. Change-Id: Ic754d9129991a08ba0e2c0736b9bf46e9a439782 --- src/lib/evas/vg/evas_vg_cache.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/lib/evas/vg/evas_vg_cache.c b/src/lib/evas/vg/evas_vg_cache.c index e2fc174..652f9eb 100644 --- a/src/lib/evas/vg/evas_vg_cache.c +++ b/src/lib/evas/vg/evas_vg_cache.c @@ -150,15 +150,21 @@ _evas_cache_vg_entry_free_cb(void *data) if (vg_entry->vfd) { vg_entry->vfd->ref--; - if (vg_entry->vfd->ref <= 0 && !vg_entry->vfd->no_share) + + if (vg_entry->vfd->ref <= 0) { - Eina_Strbuf *hash_key = eina_strbuf_new(); - eina_strbuf_append_printf(hash_key, "%s/%s", - eina_file_filename_get(vg_entry->file), - vg_entry->key); - if (!eina_hash_del(vg_cache->vfd_hash, eina_strbuf_string_get(hash_key), vg_entry->vfd)) - ERR("Failed to delete vfd = (%p) from hash", vg_entry->vfd); - eina_strbuf_free(hash_key); + if (vg_entry->vfd->no_share) + vg_entry->vfd->loader->file_close(vg_entry->vfd); + else + { + Eina_Strbuf *hash_key = eina_strbuf_new(); + eina_strbuf_append_printf(hash_key, "%s/%s", + eina_file_filename_get(vg_entry->file), + vg_entry->key); + if (!eina_hash_del(vg_cache->vfd_hash, eina_strbuf_string_get(hash_key), vg_entry->vfd)) + ERR("Failed to delete vfd = (%p) from hash", vg_entry->vfd); + eina_strbuf_free(hash_key); + } } } -- 2.7.4