From 6cad9db1f36944992eb324c8708bdf4c3c91b900 Mon Sep 17 00:00:00 2001 From: Bobby Holley Date: Mon, 18 Aug 2014 14:18:38 -0700 Subject: [PATCH] Bug 1050340 - Access regexp guts generically. r=luke --- js/src/vm/StructuredClone.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/js/src/vm/StructuredClone.cpp b/js/src/vm/StructuredClone.cpp index bc838cfbf23..7032ae395e5 100644 --- a/js/src/vm/StructuredClone.cpp +++ b/js/src/vm/StructuredClone.cpp @@ -1011,10 +1011,12 @@ JSStructuredCloneWriter::startWrite(HandleValue v) if (backref) return true; - if (obj->is()) { - RegExpObject &reobj = obj->as(); - return out.writePair(SCTAG_REGEXP_OBJECT, reobj.getFlags()) && - writeString(SCTAG_STRING, reobj.getSource()); + if (ObjectClassIs(obj, ESClass_RegExp, context())) { + RegExpGuard re(context()); + if (!RegExpToShared(context(), obj, &re)) + return false; + return out.writePair(SCTAG_REGEXP_OBJECT, re->getFlags()) && + writeString(SCTAG_STRING, re->getSource()); } else if (obj->is()) { double d = js_DateGetMsecSinceEpoch(obj); return out.writePair(SCTAG_DATE_OBJECT, 0) && out.writeDouble(d);