Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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

  • Loading branch information...
commit b662a8024453c2f29eeadb23a3ee23610a5eaa93 1 parent 6aff118
@jswalden jswalden authored
Showing with 6 additions and 4 deletions.
  1. +6 −4 js/src/jsregexp.cpp
View
10 js/src/jsregexp.cpp
@@ -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.