changeset 20397:b9bd8786d310

fix incompatibility in mxCreateNumericArray (bug #45319) * mex.cc (mxArray_matlab::mxArray_matlab): Create empty array if ndims_arg is 0. If ndims_arg < 2, initialize dims to [1, 1].
author John W. Eaton <jwe@octave.org>
date Thu, 16 Jul 2015 14:19:47 -0400
parents bf92a14c0e76
children 63736167fb78
files libinterp/corefcn/mex.cc
diffstat 1 files changed, 6 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/corefcn/mex.cc	Thu Jul 16 13:49:51 2015 -0400
+++ b/libinterp/corefcn/mex.cc	Thu Jul 16 14:19:47 2015 -0400
@@ -615,11 +615,16 @@
       ndims (ndims_arg < 2 ? 2 : ndims_arg),
       dims (static_cast<mwSize *> (mxArray::malloc (ndims * sizeof (mwSize))))
   {
-    if (ndims_arg < 2)
+    if (ndims_arg == 0)
       {
         dims[0] = 0;
         dims[1] = 0;
       }
+    else if (ndims_arg < 2)
+      {
+        dims[0] = 1;
+        dims[1] = 1;
+      }
 
     for (mwIndex i = 0; i < ndims_arg; i++)
       dims[i] = dims_arg[i];