Mercurial > octave
changeset 25446:1eedd589fb3e
maint: Merge stable to default.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Mon, 11 Jun 2018 13:07:55 -0400 |
parents | 37132909ac91 (current diff) 97e64c23fd07 (diff) |
children | fa66d81d0956 |
files | libinterp/corefcn/mex.cc |
diffstat | 1 files changed, 11 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/corefcn/mex.cc Sat Jun 09 20:01:38 2018 -0500 +++ b/libinterp/corefcn/mex.cc Mon Jun 11 13:07:55 2018 -0400 @@ -2469,18 +2469,27 @@ return ptr; } +static mxArray * +make_empty_matrix (void) +{ + static const mwSize zero = 0; + + return new mxArray (mxDOUBLE_CLASS, zero, zero, mxREAL); +} + void mxArray_struct::set_field_by_number (mwIndex index, int key_num, mxArray *val) { if (key_num >= 0 && key_num < nfields) - data[nfields * index + key_num] = maybe_unmark_array (val); + data[nfields * index + key_num] + = val ? maybe_unmark_array (val) : make_empty_matrix (); } void mxArray_cell::set_cell (mwIndex idx, mxArray *val) { if (idx >= 0 && idx < get_number_of_elements ()) - data[idx] = maybe_unmark_array (val); + data[idx] = val ? maybe_unmark_array (val) : make_empty_matrix (); } // ------------------------------------------------------------------