Skip to content

Commit fd1b20f

Browse files
committed
After r130344, OpaqueJSString::string() shouldn't directly return the wrapped String
https://bugs.webkit.org/show_bug.cgi?id=98801 Reviewed by Geoffrey Garen. Return a copy of the wrapped String so that the wrapped string cannot be turned into an Identifier. * API/OpaqueJSString.cpp: (OpaqueJSString::string): * API/OpaqueJSString.h: (OpaqueJSString): Canonical link: https://commits.webkit.org/116908@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@130931 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent f63fea3 commit fd1b20f

3 files changed

Lines changed: 25 additions & 1 deletion

File tree

Source/JavaScriptCore/API/OpaqueJSString.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,15 @@ PassRefPtr<OpaqueJSString> OpaqueJSString::create(const String& string)
3939
return 0;
4040
}
4141

42+
String OpaqueJSString::string() const
43+
{
44+
if (!this)
45+
return String();
46+
47+
// Return a copy of the wrapped string, because the caller may make it an Identifier.
48+
return m_string.isolatedCopy();
49+
}
50+
4251
Identifier OpaqueJSString::identifier(JSGlobalData* globalData) const
4352
{
4453
if (!this || !m_string.length())

Source/JavaScriptCore/API/OpaqueJSString.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ struct OpaqueJSString : public ThreadSafeRefCounted<OpaqueJSString> {
5151
const UChar* characters() { return !!this ? m_string.characters() : 0; }
5252
unsigned length() { return !!this ? m_string.length() : 0; }
5353

54-
String string() const { return !!this ? m_string : String(); };
54+
String string() const;
5555
JSC::Identifier identifier(JSC::JSGlobalData*) const;
5656

5757
private:

Source/JavaScriptCore/ChangeLog

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
2012-10-10 Michael Saboff <[email protected]>
2+
3+
After r130344, OpaqueJSString::string() shouldn't directly return the wrapped String
4+
https://bugs.webkit.org/show_bug.cgi?id=98801
5+
6+
Reviewed by Geoffrey Garen.
7+
8+
Return a copy of the wrapped String so that the wrapped string cannot be turned into
9+
an Identifier.
10+
11+
* API/OpaqueJSString.cpp:
12+
(OpaqueJSString::string):
13+
* API/OpaqueJSString.h:
14+
(OpaqueJSString):
15+
116
2012-10-10 Peter Gal <[email protected]>
217

318
Add moveDoubleToInts and moveIntsToDouble to MacroAssemblerARM

0 commit comments

Comments
 (0)