Bug 1175538 - Ensure str_split result object has the right group. r=jandem
authorBrian Hackett <bhackett1024@gmail.com>
Wed, 05 Aug 2015 11:53:01 -0400
changeset 287982 7ce747f01b726348dbe01ab143146acbd4ecdd88
parent 287981 c245eafc48bd5166b98e5f7e0cfc43fc6645dc90
child 287983 84f78a49e2d7a098810efdbff04e331588207e5a
push id5067
push userraliiev@mozilla.com
push dateMon, 21 Sep 2015 14:04:52 +0000
treeherdermozilla-beta@14221ffe5b2f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjandem
bugs1175538
milestone42.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1175538 - Ensure str_split result object has the right group. r=jandem
js/src/jsstr.cpp
--- a/js/src/jsstr.cpp
+++ b/js/src/jsstr.cpp
@@ -3741,17 +3741,17 @@ SplitHelper(JSContext* cx, HandleLinearS
 }
 
 // Fast-path for splitting a string into a character array via split("").
 static JSObject*
 CharSplitHelper(JSContext* cx, HandleLinearString str, uint32_t limit, HandleObjectGroup group)
 {
     size_t strLength = str->length();
     if (strLength == 0)
-        return NewDenseEmptyArray(cx);
+        return NewFullyAllocatedArrayTryUseGroup(cx, group, 0);
 
     js::StaticStrings& staticStrings = cx->staticStrings();
     uint32_t resultlen = (limit < strLength ? limit : strLength);
 
     AutoValueVector splits(cx);
     if (!splits.reserve(resultlen))
         return nullptr;
 
@@ -3912,16 +3912,17 @@ js::str_split(JSContext* cx, unsigned ar
             return false;
         SplitRegExpMatcher matcher(*re, res);
         aobj = SplitHelper(cx, linearStr, limit, matcher, group);
     }
     if (!aobj)
         return false;
 
     /* Step 16. */
+    MOZ_ASSERT(aobj->group() == group);
     args.rval().setObject(*aobj);
     return true;
 }
 
 JSObject*
 js::str_split_string(JSContext* cx, HandleObjectGroup group, HandleString str, HandleString sep)
 {
     RootedLinearString linearStr(cx, str->ensureLinear(cx));