changeset 9831:737624cb7560

list_in_columns: Don't SIGFPE when given empty first argument
author David Grundberg <davidg@cs.umu.se>
date Wed, 18 Nov 2009 15:50:54 +0100
parents 6748616e2f8b
children cd0c4a5a12c8
files liboctave/ChangeLog liboctave/str-vec.cc
diffstat 2 files changed, 13 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/liboctave/ChangeLog	Wed Nov 18 13:56:54 2009 +0100
+++ b/liboctave/ChangeLog	Wed Nov 18 15:50:54 2009 +0100
@@ -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-11-18  Jaroslav Hajek  <highegg@gmail.com>
 
 	* Sparse.h (read_sparse_matrix): Fix order of tests and reads. 
--- a/liboctave/str-vec.cc	Wed Nov 18 13:56:54 2009 +0100
+++ b/liboctave/str-vec.cc	Wed Nov 18 15:50:54 2009 +0100
@@ -197,6 +197,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 ();