Mercurial > octave-nkf
comparison liboctave/str-vec.cc @ 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 | f9347eac65dc |
children | fd0a3ac60b0e |
comparison
equal
deleted
inserted
replaced
10476:f261f936bf36 | 10477:a9649f994b07 |
---|---|
78 string_vector::string_vector (const char * const *s) | 78 string_vector::string_vector (const char * const *s) |
79 : Array<std::string> () | 79 : Array<std::string> () |
80 { | 80 { |
81 octave_idx_type n = 0; | 81 octave_idx_type n = 0; |
82 | 82 |
83 const char * const *t = s; | 83 if (s) |
84 | 84 { |
85 while (*t++) | 85 const char * const *t = s; |
86 n++; | 86 |
87 while (*t++) | |
88 n++; | |
89 } | |
87 | 90 |
88 resize (n); | 91 resize (n); |
89 | 92 |
90 for (octave_idx_type i = 0; i < n; i++) | 93 for (octave_idx_type i = 0; i < n; i++) |
91 elem (i) = s[i]; | 94 elem (i) = s[i]; |