File tree Expand file tree Collapse file tree 3 files changed +26
-2
lines changed Expand file tree Collapse file tree 3 files changed +26
-2
lines changed Original file line number Diff line number Diff line change @@ -260,8 +260,9 @@ namespace Js
260
260
if (JavascriptString::Is (args[1 ]))
261
261
{
262
262
JavascriptString* StringObject = JavascriptString::FromVar (args[1 ]);
263
+ const char16 * str = StringObject->GetString ();
263
264
264
- if (wcscmp (StringObject-> UnsafeGetBuffer () , _u (" default" )) == 0 || wcscmp (StringObject-> UnsafeGetBuffer () , _u (" string" )) == 0 )
265
+ if (wcscmp (str , _u (" default" )) == 0 || wcscmp (str , _u (" string" )) == 0 )
265
266
{
266
267
// Date objects, are unique among built-in ECMAScript object in that they treat "default" as being equivalent to "string"
267
268
// If hint is the string value "string" or the string value "default", then
@@ -270,7 +271,7 @@ namespace Js
270
271
}
271
272
// Else if hint is the string value "number", then
272
273
// Let tryFirst be "number".
273
- else if (wcscmp (StringObject-> UnsafeGetBuffer () , _u (" number" )) == 0 )
274
+ else if (wcscmp (str , _u (" number" )) == 0 )
274
275
{
275
276
return JavascriptConversion::OrdinaryToPrimitive (args[0 ], JavascriptHint::HintNumber/* tryFirst*/ , scriptContext);
276
277
}
Original file line number Diff line number Diff line change
1
+ //-------------------------------------------------------------------------------------------------------
2
+ // Copyright (C) Microsoft. All rights reserved.
3
+ // Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
4
+ //-------------------------------------------------------------------------------------------------------
5
+
6
+ WScript . LoadScriptFile ( "..\\UnitTestFramework\\UnitTestFramework.js" ) ;
7
+
8
+ var tests = [
9
+ {
10
+ name : "calling Symbol.toPrimitive on Date prototype should not AV" ,
11
+ body : function ( ) {
12
+ Date . prototype [ Symbol . toPrimitive ] . call ( { } , 'strin' + 'g' ) ;
13
+ }
14
+ }
15
+ ] ;
16
+
17
+ testRunner . runTests ( tests , { verbose : WScript . Arguments [ 0 ] != "summary" } ) ;
Original file line number Diff line number Diff line change 305
305
<compile-flags >-args summary -endargs</compile-flags >
306
306
</default >
307
307
</test >
308
+ <test >
309
+ <default >
310
+ <files >misc_bugs.js</files >
311
+ <compile-flags >-args summary -endargs</compile-flags >
312
+ </default >
313
+ </test >
308
314
<test >
309
315
<default >
310
316
<files >json_bugs.js</files >
You can’t perform that action at this time.
0 commit comments