Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Bug 637859. Anchor a string for a bit. r=cdleary, a=bsmedberg

  • Loading branch information...
commit e974b414d62193fe7dd000e4131621e6fd4b11fe 1 parent cc99f71
Jeff Walden jswalden authored
Showing with 6 additions and 4 deletions.
  1. +6 −4 js/src/jsregexp.cpp
10 js/src/jsregexp.cpp
View
@@ -640,6 +640,7 @@ EscapeNakedForwardSlashes(JSContext *cx, JSString *unescaped)
const jschar *oldChars = unescaped->getChars(cx);
if (!oldChars)
return NULL;
+ JS::Anchor<JSString *> anchor(unescaped);
js::Vector<jschar, 128> newChars(cx);
for (const jschar *it = oldChars; it < oldChars + oldLen; ++it) {
@@ -647,13 +648,14 @@ EscapeNakedForwardSlashes(JSContext *cx, JSString *unescaped)
if (!newChars.length()) {
if (!newChars.reserve(oldLen + 1))
return NULL;
- newChars.append(oldChars, size_t(it - oldChars));
+ JS_ALWAYS_TRUE(newChars.append(oldChars, size_t(it - oldChars)));
}
- newChars.append('\\');
+ if (!newChars.append('\\'))
+ return NULL;
}
- if (newChars.length())
- newChars.append(*it);
+ if (!newChars.empty() && !newChars.append(*it))
+ return NULL;
}
if (newChars.length()) {
Please sign in to comment.
Something went wrong with that request. Please try again.