summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Examples/test-suite/octave/overload_null_runme.m52
-rw-r--r--Lib/octave/octrun.swg2
2 files changed, 53 insertions, 1 deletions
diff --git a/Examples/test-suite/octave/overload_null_runme.m b/Examples/test-suite/octave/overload_null_runme.m
new file mode 100644
index 000000000..a7c346c26
--- /dev/null
+++ b/Examples/test-suite/octave/overload_null_runme.m
@@ -0,0 +1,52 @@
+# do not dump Octave core
+if exist("crash_dumps_octave_core", "builtin")
+ crash_dumps_octave_core(0);
+endif
+
+overload_null
+
+function check(a, b)
+ if (a != b)
+ error("%i does not equal %i", a, b);
+ endif
+end
+
+o = Overload();
+x = X();
+null = []; # NULL pointer
+
+check(1, o.byval1(x));
+check(2, o.byval1(null));
+
+check(3, o.byval2(null));
+check(4, o.byval2(x));
+
+check(5, o.byref1(x));
+check(6, o.byref1(null));
+
+check(7, o.byref2(null));
+check(8, o.byref2(x));
+
+check(9, o.byconstref1(x));
+check(10, o.byconstref1(null));
+
+check(11, o.byconstref2(null));
+check(12, o.byconstref2(x));
+
+# const pointer references
+check(13, o.byval1cpr(x));
+check(14, o.byval1cpr(null));
+
+check(15, o.byval2cpr(null));
+check(16, o.byval2cpr(x));
+
+# forward class declaration
+check(17, o.byval1forwardptr(x));
+check(18, o.byval1forwardptr(null));
+
+check(19, o.byval2forwardptr(null));
+check(20, o.byval2forwardptr(x));
+
+check(21, o.byval1forwardref(x));
+
+check(22, o.byval2forwardref(x));
diff --git a/Lib/octave/octrun.swg b/Lib/octave/octrun.swg
index feed973cc..301233103 100644
--- a/Lib/octave/octrun.swg
+++ b/Lib/octave/octrun.swg
@@ -1477,7 +1477,7 @@ SWIGRUNTIME int SWIG_Octave_ConvertPtrAndOwn(octave_value ov, void **ptr, swig_t
(ov.is_matrix_type() && ov.rows() == 0 && ov.columns() == 0) ) {
if (ptr)
*ptr = 0;
- return SWIG_OK;
+ return (flags & SWIG_POINTER_NO_NULL) ? SWIG_NullReferenceError : SWIG_OK;
}
if (ov.type_id() != octave_swig_ref::static_type_id())
return SWIG_ERROR;