diff options
author | Nicolas "Pixel" Noble <pixel@nobis-crew.org> | 2010-11-29 10:29:12 +0100 |
---|---|---|
committer | Nicolas "Pixel" Noble <pixel@nobis-crew.org> | 2010-11-29 10:29:12 +0100 |
commit | c7f53415c7dc0445ae58a790fc5bf51725a66d9c (patch) | |
tree | e7c07b077f56b542cfad0483d0ce16c61ce6ffff /lib/String.cc | |
parent | c9e876553534f55da53f30b846a9ec61ad8e0275 (diff) |
Making it so the [] operator doesn't crash if reading out of bounds - gcc is stupid for not calling the proper operator here.
Diffstat (limited to 'lib/String.cc')
-rw-r--r-- | lib/String.cc | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/String.cc b/lib/String.cc index 7300365..47315b6 100644 --- a/lib/String.cc +++ b/lib/String.cc @@ -388,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]; } |