From c7f53415c7dc0445ae58a790fc5bf51725a66d9c Mon Sep 17 00:00:00 2001
From: "Nicolas \"Pixel\" Noble" <pixel@nobis-crew.org>
Date: Mon, 29 Nov 2010 10:29:12 +0100
Subject: Making it so the [] operator doesn't crash if reading out of bounds -
 gcc is stupid for not calling the proper operator here.

---
 lib/String.cc | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

(limited to 'lib')

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];
     }
-- 
cgit v1.2.3