]> git.lizzy.rs Git - irrlicht.git/blobdiff - include/irrString.h
Fix various GCC warnings
[irrlicht.git] / include / irrString.h
index 3178c3969455647320e36b83a7548d5502a9afe8..f454aed483f2a31598c3fa1c3415303f5cc2c189 100644 (file)
@@ -920,8 +920,10 @@ public:
                if ((length+begin) > size())\r
                        length = size()-begin;\r
 \r
+               // accounting for null terminator.\r
+               s32 substrAllocLength = length + 1;\r
                string<T> o;\r
-               o.reserve(length+1);\r
+               o.reserve(substrAllocLength);\r
 \r
                if ( !make_lower )\r
                {\r
@@ -934,7 +936,7 @@ public:
                                o.array[i] = locale_lower ( array[i+begin] );\r
                }\r
 \r
-               o.array[length] = 0;\r
+               o.array[substrAllocLength - 1] = 0;\r
                o.used = length + 1;\r
 \r
                return o;\r