aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLauro Moura <lauromoura@expertisesolutions.com.br>2019-04-02 16:47:36 +0200
committerXavi Artigas <xavierartigas@yahoo.es>2019-04-02 16:48:39 +0200
commit731db8b64403c06c36a27c6a73b13c4b04a9aacd (patch)
treee6b15b341753611f62f8fc46bf6689da5c18cbcf
parentremove useless check of ws2tcpip.h (diff)
downloadefl-731db8b64403c06c36a27c6a73b13c4b04a9aacd.tar.gz
csharp: Raise exception when Array is null.
Reviewers: felipealmeida, vitor.sousa, segfaultxavi Reviewed By: vitor.sousa Subscribers: cedric, #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D8499
-rw-r--r--src/bindings/mono/eina_mono/eina_array.cs10
-rw-r--r--src/tests/efl_mono/Eina.cs6
2 files changed, 16 insertions, 0 deletions
diff --git a/src/bindings/mono/eina_mono/eina_array.cs b/src/bindings/mono/eina_mono/eina_array.cs
index f4dd49d69e..b2cdede565 100644
--- a/src/bindings/mono/eina_mono/eina_array.cs
+++ b/src/bindings/mono/eina_mono/eina_array.cs
@@ -99,6 +99,11 @@ public class Array<T> : IEnumerable<T>, IDisposable
public Array(IntPtr handle, bool own)
{
+ if (handle == IntPtr.Zero)
+ {
+ throw new ArgumentNullException("Handle can't be null");
+ }
+
Handle = handle;
Own = own;
OwnContent = own;
@@ -106,6 +111,11 @@ public class Array<T> : IEnumerable<T>, IDisposable
public Array(IntPtr handle, bool own, bool ownContent)
{
+ if (handle == IntPtr.Zero)
+ {
+ throw new ArgumentNullException("Handle can't be null");
+ }
+
Handle = handle;
Own = own;
OwnContent = ownContent;
diff --git a/src/tests/efl_mono/Eina.cs b/src/tests/efl_mono/Eina.cs
index 8b7f1a9672..6a07e2f288 100644
--- a/src/tests/efl_mono/Eina.cs
+++ b/src/tests/efl_mono/Eina.cs
@@ -460,6 +460,12 @@ class TestEinaArray
Test.Assert(a.Handle != IntPtr.Zero);
}
+ public static void create_array_from_null()
+ {
+ Test.AssertRaises<ArgumentNullException>(() => new Eina.Array<int>(IntPtr.Zero, false));
+ Test.AssertRaises<ArgumentNullException>(() => new Eina.Array<int>(IntPtr.Zero, false, false));
+ }
+
public static void push_int()
{
var a = new Eina.Array<int>();