# HG changeset patch # User Jaroslav Hajek # Date 1277367284 -7200 # Node ID 58c1b54025882fa78a74e5a30b3ce639ba8c4df4 # Parent 93422177b697a0c1137eb2aa429aafd48687e0de fix a showstopping bug in octave_fields reference counting diff --git a/src/oct-map.h b/src/oct-map.h --- a/src/oct-map.h +++ b/src/oct-map.h @@ -80,7 +80,7 @@ operator = (const octave_fields& o) { o.rep->count++; - if (--rep->count) + if (--rep->count == 0) delete rep; rep = o.rep; diff --git a/src/ov-struct.cc b/src/ov-struct.cc --- a/src/ov-struct.cc +++ b/src/ov-struct.cc @@ -1724,10 +1724,12 @@ // Note that struct () creates a 1x1 struct with no fields for // compatibility with Matlab. + if (nargin == 1 && args(0).is_map ()) + return args(0); + if (nargin == 1 && args(0).is_object ()) { - octave_map m = args(0).map_value (); - retval = octave_value (new octave_struct (m)); + retval = args(0).map_value (); return retval; }