Title: [262296] trunk/Source/_javascript_Core
Revision
262296
Author
[email protected]
Date
2020-05-29 09:01:06 -0700 (Fri, 29 May 2020)

Log Message

Add a check for errors when computing a utf string in jsc shell's runInteractive().
https://bugs.webkit.org/show_bug.cgi?id=212526
<rdar://problem/63757892>

Reviewed by Michael Saboff.

* jsc.cpp:
(runInteractive):

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (262295 => 262296)


--- trunk/Source/_javascript_Core/ChangeLog	2020-05-29 15:47:40 UTC (rev 262295)
+++ trunk/Source/_javascript_Core/ChangeLog	2020-05-29 16:01:06 UTC (rev 262296)
@@ -1,3 +1,14 @@
+2020-05-29  Mark Lam  <[email protected]>
+
+        Add a check for errors when computing a utf string in jsc shell's runInteractive().
+        https://bugs.webkit.org/show_bug.cgi?id=212526
+        <rdar://problem/63757892>
+
+        Reviewed by Michael Saboff.
+
+        * jsc.cpp:
+        (runInteractive):
+
 2020-05-28  Devin Rousso  <[email protected]>
 
         Web Inspector: add missing condition guards when generating objc protocol files

Modified: trunk/Source/_javascript_Core/jsc.cpp (262295 => 262296)


--- trunk/Source/_javascript_Core/jsc.cpp	2020-05-29 15:47:40 UTC (rev 262295)
+++ trunk/Source/_javascript_Core/jsc.cpp	2020-05-29 16:01:06 UTC (rev 262296)
@@ -2858,12 +2858,20 @@
         NakedPtr<Exception> evaluationException;
         JSValue returnValue = evaluate(globalObject, jscSource(line, sourceOrigin, sourceOrigin.string()), JSValue(), evaluationException);
 #endif
-        CString result;
+        Expected<CString, UTF8ConversionError> utf8;
         if (evaluationException) {
             fputs("Exception: ", stdout);
-            result = evaluationException->value().toWTFString(globalObject).utf8();
+            utf8 = evaluationException->value().toWTFString(globalObject).tryGetUtf8();
         } else
-            result = returnValue.toWTFString(globalObject).utf8();
+            utf8 = returnValue.toWTFString(globalObject).tryGetUtf8();
+
+        CString result;
+        if (utf8)
+            result = utf8.value();
+        else if (utf8.error() == UTF8ConversionError::OutOfMemory)
+            result = "OutOfMemory while processing string";
+        else
+            result = "Error while processing string";
         fwrite(result.data(), sizeof(char), result.length(), stdout);
         putchar('\n');
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to