changeset 10477:a9649f994b07

avoid segfault in string_vector constructor
author John W. Eaton <jwe@octave.org>
date Tue, 30 Mar 2010 15:24:39 -0400
parents f261f936bf36
children d382db6b9d81
files liboctave/ChangeLog liboctave/str-vec.cc
diffstat 2 files changed, 11 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/liboctave/ChangeLog	Tue Mar 30 21:04:27 2010 +0200
+++ b/liboctave/ChangeLog	Tue Mar 30 15:24:39 2010 -0400
@@ -1,3 +1,8 @@
+2010-03-30  John W. Eaton  <jwe@octave.org>
+
+	* str-vec.cc (string_vector::string_vector (const char * const *)): 
+	Create empty string_vector object if arg is NULL.
+
 2010-03-29  Jaroslav Hajek  <highegg@gmail.com>
 
 	* idx-vector.cc (idx_vector::raw): New method.
--- a/liboctave/str-vec.cc	Tue Mar 30 21:04:27 2010 +0200
+++ b/liboctave/str-vec.cc	Tue Mar 30 15:24:39 2010 -0400
@@ -80,10 +80,13 @@
 {
   octave_idx_type n = 0;
 
-  const char * const *t = s;
+  if (s)
+    {
+      const char * const *t = s;
 
-  while (*t++)
-    n++;
+      while (*t++)
+        n++;
+    }
 
   resize (n);