evas vg: fix a memory leak. 81/198181/1
authorHermet Park <hermetpark@gmail.com>
Tue, 22 Jan 2019 05:10:34 +0000 (14:10 +0900)
committerHermet Park <hermetpark@gmail.com>
Tue, 22 Jan 2019 06:45:55 +0000 (15:45 +0900)
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

index e2fc174..652f9eb 100644 (file)
@@ -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);
+               }
           }
      }