Bug 662001 - Use RangedPtr<T> in one location outside js/src/ to verify that mfbt/RangedPtr.h is usable by non-JS code. r=bz
authorJeff Walden <jwalden@mit.edu>
Mon, 06 Jun 2011 11:02:35 -0700
changeset 70983 e3e54ff584a82cd05544d7e8828bac32ab06c7ed
parent 70982 e6eb095ca758a469b98092b60df0861a116a6da3
child 70984 9cdb856cf910745a5f07850e86111a6a392e9e39
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersbz
bugs662001
milestone7.0a1
Bug 662001 - Use RangedPtr<T> in one location outside js/src/ to verify that mfbt/RangedPtr.h is usable by non-JS code. r=bz
netwerk/base/src/nsURLParsers.cpp
--- a/netwerk/base/src/nsURLParsers.cpp
+++ b/netwerk/base/src/nsURLParsers.cpp
@@ -32,31 +32,37 @@
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include <string.h>
+
+#include "mozilla/RangedPtr.h"
+
 #include "nsURLParsers.h"
 #include "nsURLHelper.h"
 #include "nsIURI.h"
 #include "prtypes.h"
 #include "nsString.h"
 #include "nsCRT.h"
 #include "netCore.h"
 
+using namespace mozilla;
+
 //----------------------------------------------------------------------------
 
 static PRUint32
 CountConsecutiveSlashes(const char *str, PRInt32 len)
 {
+    RangedPtr<const char> p(str, len);
     PRUint32 count = 0;
-    while (len-- && *str++ == '/') ++count;
+    while (len-- && *p++ == '/') ++count;
     return count;
 }
 
 //----------------------------------------------------------------------------
 // nsBaseURLParser implementation
 //----------------------------------------------------------------------------
 
 // The URL parser service does not have any internal state; however, it can