summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas "Pixel" Noble <pixel@nobis-crew.org>2010-11-29 10:29:12 +0100
committerNicolas "Pixel" Noble <pixel@nobis-crew.org>2010-11-29 10:29:12 +0100
commitc7f53415c7dc0445ae58a790fc5bf51725a66d9c (patch)
treee7c07b077f56b542cfad0483d0ce16c61ce6ffff
parentc9e876553534f55da53f30b846a9ec61ad8e0275 (diff)
Making it so the [] operator doesn't crash if reading out of bounds - gcc is stupid for not calling the proper operator here.
-rw-r--r--lib/String.cc5
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];
}