diff options
Diffstat (limited to 'lib/String.cc')
-rw-r--r-- | lib/String.cc | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/String.cc b/lib/String.cc index 14195f6..47315b6 100644 --- a/lib/String.cc +++ b/lib/String.cc @@ -276,8 +276,10 @@ String String::extract(size_t from, ssize_t to) const { char * String::strdup(size_t from, ssize_t to) const { char * r; - r = Base::strdup(to_charp(from, to)); - + r = Base::strdup(to_charp(from, -1)); + to -= from; + if ((to >= 0) && (to < (siz - from))) + r[to + 1] = 0; return r; } @@ -386,9 +388,10 @@ const char & String::operator[](size_t i) const { } char & String::operator[](size_t i) throw (GeneralException) { - + static char zero; if (i >= siz) { - throw GeneralException("operator[] on String out of bounds"); + zero = 0; + return zero; } else { return str[i]; } |