activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r922661 - /activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/String.cpp
Date Sat, 13 Mar 2010 19:57:47 GMT
Author: tabish
Date: Sat Mar 13 19:57:46 2010
New Revision: 922661

URL: http://svn.apache.org/viewvc?rev=922661&view=rev
Log:
Add additional range checking

Modified:
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/String.cpp

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/String.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/String.cpp?rev=922661&r1=922660&r2=922661&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/String.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/String.cpp Sat Mar 13 19:57:46
2010
@@ -104,7 +104,22 @@ char String::charAt( std::size_t index )
 CharSequence* String::subSequence( std::size_t start DECAF_UNUSED, std::size_t end DECAF_UNUSED
) const
     throw( lang::exceptions::IndexOutOfBoundsException ) {
 
-    return NULL;
+    try{
+
+        if( start > end ) {
+            throw IndexOutOfBoundsException(
+                __FILE__, __LINE__, "Start index is greater than end index." );
+        }
+
+        if( end - start > this->length() ) {
+            throw IndexOutOfBoundsException(
+                __FILE__, __LINE__, "Requested Range is greater than the String length."
);
+        }
+
+        return NULL;
+    }
+    DECAF_CATCH_RETHROW( IndexOutOfBoundsException )
+    DECAF_CATCHALL_THROW( IndexOutOfBoundsException )
 }
 
 ////////////////////////////////////////////////////////////////////////////////



Mime
View raw message