# HG changeset patch # User jwe # Date 1041371334 0 # Node ID 2b9c6dc2544931eae425174e580fae4b38e7980c # Parent f7d11c1a49e39ab9602aa4ee9326d51995c722e3 [project @ 2002-12-31 21:48:54 by jwe] diff --git a/src/ChangeLog b/src/ChangeLog --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,6 +1,8 @@ 2002-12-31 John W. Eaton * pt-arg-list.cc (F__end__): Fail if rows or columns is negative. + (tree_argument_list::convert_to_const_vector): Only protect and + save pointer to the indexed object if it is a constant. * syscalls.cc (Fmkfifo): Use long_value instead of cast. diff --git a/src/pt-arg-list.cc b/src/pt-arg-list.cc --- a/src/pt-arg-list.cc +++ b/src/pt-arg-list.cc @@ -116,11 +116,25 @@ break; case 0: - retval = indexed_object->rows (); + { + int nr = indexed_object->rows (); + + if (nr < 0) + ::error ("invalid use of end"); + else + retval = nr; + } break; case 1: - retval = indexed_object->columns (); + { + int nc = indexed_object->columns (); + + if (nc < 0) + ::error ("invalid use of end"); + else + retval = nc; + } break; default: @@ -129,7 +143,7 @@ } } else - ::error ("__end__: internal error"); + ::error ("invalid use of end"); return retval; } @@ -137,11 +151,19 @@ octave_value_list tree_argument_list::convert_to_const_vector (const octave_value *object) { - unwind_protect::begin_frame ("convert_to_const_vector"); + // END doesn't make sense for functions. Maybe we need a different + // way of asking an octave_value object this question? + + bool stash_object = (object && object->is_constant ()); - unwind_protect_ptr (indexed_object); + if (stash_object) + { + unwind_protect::begin_frame ("convert_to_const_vector"); - indexed_object = object; + unwind_protect_ptr (indexed_object); + + indexed_object = object; + } int len = length (); @@ -214,7 +236,8 @@ args.resize (j); - unwind_protect::run_frame ("convert_to_const_vector"); + if (stash_object) + unwind_protect::run_frame ("convert_to_const_vector"); return args; }