Mercurial > octave
diff libinterp/octave-value/ov-typeinfo.cc @ 24779:5f445419559f
avoid crash on exit with user-defined data types (bug #53156)
* ov-typeinfo.h, ov-typeinfo.cc (type_info::vals): Now an array
of pointers.
(type_info::register_type): Store pointer to object allocated by new
in vals array.
* Array-tc.cc: Instantiate Array<octave_value *>.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 20 Feb 2018 14:36:25 -0500 |
parents | 46440078d73b |
children | 6652d3823428 |
line wrap: on
line diff
--- a/libinterp/octave-value/ov-typeinfo.cc Mon Feb 19 11:37:36 2018 -0800 +++ b/libinterp/octave-value/ov-typeinfo.cc Tue Feb 20 14:36:25 2018 -0500 @@ -113,7 +113,7 @@ types.resize (dim_vector (len, 1), ""); - vals.resize (dim_vector (len, 1), octave_value ()); + vals.resize (dim_vector (len, 1), nullptr); unary_ops.resize (dim_vector (octave_value::num_unary_ops, len), nullptr); @@ -143,7 +143,13 @@ types (i) = t_name; - vals (i) = val; + // Yes, this object is intentionally not deleted in the destructor + // so that we avoid a crash on exit for user-defined data types. + // See bug #53156. If that problem is properly fixed, then this + // could be stored as an object instead of a pointer to an object + // allocated with new. + + vals(i) = new octave_value (val); num_types++; @@ -475,7 +481,7 @@ { if (nm == types(i)) { - retval = vals(i); + retval = *vals(i); retval.make_unique (); break; }