Browse Source

Throw out-of-bounds error from string SetLength (#6659)

Use a more appropriate error for out of bounds length in
JavascriptString::SetLength().

Closes #6625
Closes #6632
Closes #6634

Co-authored-by: Richard <[email protected]>
Petr Penzin 5 years ago
parent
commit
94d6e989f3
2 changed files with 4 additions and 4 deletions
  1. 1 1
      lib/Runtime/Library/JavascriptString.cpp
  2. 3 3
      test/Error/outofmem.baseline

+ 1 - 1
lib/Runtime/Library/JavascriptString.cpp

@@ -205,7 +205,7 @@ namespace Js
     {
         if (!IsValidCharCount(newLength))
         {
-            JavascriptExceptionOperators::ThrowOutOfMemory(this->GetScriptContext());
+            JavascriptError::ThrowRangeError(this->GetScriptContext(), JSERR_OutOfBoundString);
         }
         m_charLength = newLength;
     }

+ 3 - 3
test/Error/outofmem.baseline

@@ -1,3 +1,3 @@
-Error
-Out of memory
--2146828281
+RangeError
+String length is out of bound
+-2146822618