eina_csharp: fix memory leak in Eina.Hash.Set method
authorVitor Sousa <vitorsousa@expertisesolutions.com.br>
Thu, 7 Mar 2019 16:58:26 +0000 (16:58 +0000)
committerJunsuChoi <jsuya.choi@samsung.com>
Thu, 14 Mar 2019 05:46:27 +0000 (14:46 +0900)
Reviewed-by: Lauro Neto <Lauro Moura <lauromoura@expertisesolutions.com.br>>
Differential Revision: https://phab.enlightenment.org/D8236

src/bindings/mono/eina_mono/eina_hash.cs

index 4770870..95de7c5 100644 (file)
@@ -415,6 +415,8 @@ public class Hash<TKey, TValue> : IEnumerable<KeyValuePair<TKey, TValue>>, IDi
         IntPtr old = eina_hash_set(Handle, nk, nv);
         FreeNativeIndirection<TKey>(gchnk, ForceRefKey<TKey>());
         FreeNativeIndirection<TValue>(gchnv, false);
+        if (OwnValue || old != IntPtr.Zero)
+            NativeFree<TValue>(old);
     }
 
     public TValue this[TKey key]