changeset 12105:2641c6febd46 release-3-2-x

list_in_columns: Don't SIGFPE when given empty first argument
author David Grundberg <davidg@cs.umu.se>
date Wed, 25 Nov 2009 11:44:57 +0100
parents 69828adba966
children 11f9c592b035
files liboctave/ChangeLog liboctave/str-vec.cc
diffstat 2 files changed, 13 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/liboctave/ChangeLog
+++ b/liboctave/ChangeLog
@@ -1,3 +1,8 @@
+2009-11-18  David Grundberg  <davidg@cs.umu.se>
+
+       * str-vec.cc (string_vector::list_in_columns): Avoid crash on
+       empty arguments from list_in_columns.
+
 2009-10-27  David Bateman  <dbateman@free.fr>
 
 	* SparsedbleLU.cc (SparseLU::SparseLU (const SparseMatrix&,
--- a/liboctave/str-vec.cc
+++ b/liboctave/str-vec.cc
@@ -179,6 +179,14 @@
   octave_idx_type max_name_length = 0;
   octave_idx_type total_names = length ();
 
+  if (total_names == 0)
+    {
+      // List empty, remember to end output with a newline.
+
+      os << "\n";
+      return os;
+    }
+
   for (octave_idx_type i = 0; i < total_names; i++)
     {
       octave_idx_type name_length = elem (i).length ();