Skip to content

Commit ff79c41

Browse files
committed
[JSC] Use tryMakeString for error message on invalid destructuring
https://bugs.webkit.org/show_bug.cgi?id=300190 Reviewed by Keith Miller. This patch changes to use `tryMakeString` for error message on invalid destructuring for avoiding crash. * Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp: (JSC::BytecodeGenerator::emitRequireObjectCoercibleForDestructuring): Canonical link: https://commits.webkit.org/301053@main
1 parent d46abac commit ff79c41

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4994,9 +4994,13 @@ void BytecodeGenerator::emitRequireObjectCoercibleForDestructuring(RegisterID* v
49944994
Ref<Label> target = newLabel();
49954995
OpJnundefinedOrNull::emit(this, value, target->bind(this));
49964996

4997-
if (propertyName && !propertyName->isNull())
4998-
emitThrowTypeError(Identifier::fromString(m_vm, makeString("Cannot destructure property '"_s, propertyName->string(), "' from null or undefined value"_s)));
4999-
else
4997+
if (propertyName && !propertyName->isNull()) {
4998+
auto errorMessageStr = tryMakeString("Cannot destructure property '"_s, propertyName->string(), "' from null or undefined value"_s);
4999+
if (!errorMessageStr) [[unlikely]]
5000+
emitThrowTypeError("Cannot destructure null or undefined value"_s);
5001+
else
5002+
emitThrowTypeError(Identifier::fromString(m_vm, errorMessageStr));
5003+
} else
50005004
emitThrowTypeError("Cannot destructure null or undefined value"_s);
50015005

50025006
emitLabel(target.get());

0 commit comments

Comments
 (0)