comparison libinterp/corefcn/mex.cc @ 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 2691947f5409
children 2d9ec16fa960
comparison
equal deleted inserted replaced
20396:bf92a14c0e76 20397:b9bd8786d310
613 mxArray_matlab (mxClassID id_arg, mwSize ndims_arg, const mwSize *dims_arg) 613 mxArray_matlab (mxClassID id_arg, mwSize ndims_arg, const mwSize *dims_arg)
614 : mxArray_base (), class_name (0), id (id_arg), 614 : mxArray_base (), class_name (0), id (id_arg),
615 ndims (ndims_arg < 2 ? 2 : ndims_arg), 615 ndims (ndims_arg < 2 ? 2 : ndims_arg),
616 dims (static_cast<mwSize *> (mxArray::malloc (ndims * sizeof (mwSize)))) 616 dims (static_cast<mwSize *> (mxArray::malloc (ndims * sizeof (mwSize))))
617 { 617 {
618 if (ndims_arg < 2) 618 if (ndims_arg == 0)
619 { 619 {
620 dims[0] = 0; 620 dims[0] = 0;
621 dims[1] = 0; 621 dims[1] = 0;
622 }
623 else if (ndims_arg < 2)
624 {
625 dims[0] = 1;
626 dims[1] = 1;
622 } 627 }
623 628
624 for (mwIndex i = 0; i < ndims_arg; i++) 629 for (mwIndex i = 0; i < ndims_arg; i++)
625 dims[i] = dims_arg[i]; 630 dims[i] = dims_arg[i];
626 631