WebKit Bugzilla
Attachment 348836 Details for
Bug 189268
: Make the jsc shell print, printErr, and debug functions more robust.
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
proposed patch.
bug-189268.patch (text/plain), 3.34 KB, created by
Mark Lam
on 2018-09-04 12:11:13 PDT
(
hide
)
Description:
proposed patch.
Filename:
MIME Type:
Creator:
Mark Lam
Created:
2018-09-04 12:11:13 PDT
Size:
3.34 KB
patch
obsolete
>Index: Source/JavaScriptCore/ChangeLog >=================================================================== >--- Source/JavaScriptCore/ChangeLog (revision 235624) >+++ Source/JavaScriptCore/ChangeLog (working copy) >@@ -1,3 +1,18 @@ >+2018-09-04 Mark Lam <mark.lam@apple.com> >+ >+ Make the jsc shell print, printErr, and debug functions more robust. >+ https://bugs.webkit.org/show_bug.cgi?id=189268 >+ <rdar://problem/41192690> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ We'll now check for UTF8 conversion errors. >+ >+ * jsc.cpp: >+ (cStringFromViewWithString): >+ (printInternal): >+ (functionDebug): >+ > 2018-09-04 Michael Catanzaro <mcatanzaro@igalia.com> > > [WPE][GTK] Add more unused result warnings to JSC API >Index: Source/JavaScriptCore/jsc.cpp >=================================================================== >--- Source/JavaScriptCore/jsc.cpp (revision 235613) >+++ Source/JavaScriptCore/jsc.cpp (working copy) >@@ -1,6 +1,6 @@ > /* > * Copyright (C) 1999-2000 Harri Porten (porten@kde.org) >- * Copyright (C) 2004-2017 Apple Inc. All rights reserved. >+ * Copyright (C) 2004-2018 Apple Inc. All rights reserved. > * Copyright (C) 2006 Bjoern Graf (bjoern.graf@gmail.com) > * > * This library is free software; you can redistribute it and/or >@@ -1014,6 +1014,27 @@ JSObject* GlobalObject::moduleLoaderCrea > return metaProperties; > } > >+static CString cStringFromViewWithString(ExecState* exec, ThrowScope& scope, StringViewWithUnderlyingString& viewWithString) >+{ >+ Expected<CString, UTF8ConversionError> expectedString = viewWithString.view.tryGetUtf8(); >+ if (expectedString) >+ return expectedString.value(); >+ switch (expectedString.error()) { >+ case UTF8ConversionError::OutOfMemory: >+ throwOutOfMemoryError(exec, scope); >+ break; >+ case UTF8ConversionError::IllegalSource: >+ scope.throwException(exec, createError(exec, "Illegal source encountered during UTF8 conversion")); >+ break; >+ case UTF8ConversionError::SourceExhausted: >+ scope.throwException(exec, createError(exec, "Source exhausted encountered during UTF8 conversion")); >+ break; >+ default: >+ RELEASE_ASSERT_NOT_REACHED(); >+ } >+ return { }; >+} >+ > static EncodedJSValue printInternal(ExecState* exec, FILE* out) > { > VM& vm = exec->vm(); >@@ -1034,7 +1055,9 @@ static EncodedJSValue printInternal(Exec > > auto viewWithString = exec->uncheckedArgument(i).toString(exec)->viewWithUnderlyingString(exec); > RETURN_IF_EXCEPTION(scope, encodedJSValue()); >- if (fprintf(out, "%s", viewWithString.view.utf8().data()) < 0) >+ auto string = cStringFromViewWithString(exec, scope, viewWithString); >+ RETURN_IF_EXCEPTION(scope, encodedJSValue()); >+ if (fprintf(out, "%s", string.data()) < 0) > goto fail; > } > >@@ -1053,7 +1076,9 @@ EncodedJSValue JSC_HOST_CALL functionDeb > auto scope = DECLARE_THROW_SCOPE(vm); > auto viewWithString = exec->argument(0).toString(exec)->viewWithUnderlyingString(exec); > RETURN_IF_EXCEPTION(scope, encodedJSValue()); >- fprintf(stderr, "--> %s\n", viewWithString.view.utf8().data()); >+ auto string = cStringFromViewWithString(exec, scope, viewWithString); >+ RETURN_IF_EXCEPTION(scope, encodedJSValue()); >+ fprintf(stderr, "--> %s\n", string.data()); > return JSValue::encode(jsUndefined()); > } >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
keith_miller
:
review+
mark.lam
:
commit-queue-
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 189268
: 348836