mirror of
https://github.com/oven-sh/bun
synced 2026-02-12 11:59:00 +00:00
Handle stack overflow in binary expressions in JS Parser (#7414)
* Fix stack overflow in large files * Add test for stack overflow * wip * Disable cache in debug build * Remove our extra `captureStackTrace` call * Update RuntimeTranspilerCache.zig * Update RuntimeTranspilerCache.zig * Fix issues with integer environment variables * Add missing ref * Add missing null check * Update bindings.cpp * Update transpiler-cache.test.ts * Add version check --------- Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
This commit is contained in:
@@ -135,7 +135,26 @@ JSValue createEnvironmentVariablesMap(Zig::GlobalObject* globalObject)
|
||||
hasTZ = true;
|
||||
continue;
|
||||
}
|
||||
object->putDirectCustomAccessor(vm, Identifier::fromString(vm, name), JSC::CustomGetterSetter::create(vm, jsGetterEnvironmentVariable, jsSetterEnvironmentVariable), JSC::PropertyAttribute::CustomAccessor | 0);
|
||||
ASSERT(len > 0);
|
||||
|
||||
Identifier identifier = Identifier::fromString(vm, name);
|
||||
|
||||
// CustomGetterSetter doesn't support indexed properties yet.
|
||||
// This causes strange issues when the environment variable name is an integer.
|
||||
if (UNLIKELY(chars[0] >= '0' && chars[0] <= '9')) {
|
||||
if (auto index = parseIndex(identifier)) {
|
||||
ZigString valueString = { nullptr, 0 };
|
||||
ZigString nameStr = toZigString(name);
|
||||
JSValue value = jsUndefined();
|
||||
if (Bun__getEnvValue(globalObject, &nameStr, &valueString)) {
|
||||
value = jsString(vm, Zig::toStringCopy(valueString));
|
||||
}
|
||||
object->putDirectIndex(globalObject, *index, value, 0, PutDirectIndexLikePutDirect);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
object->putDirectCustomAccessor(vm, identifier, JSC::CustomGetterSetter::create(vm, jsGetterEnvironmentVariable, jsSetterEnvironmentVariable), JSC::PropertyAttribute::CustomAccessor | 0);
|
||||
}
|
||||
|
||||
unsigned int TZAttrs = JSC::PropertyAttribute::CustomAccessor | 0;
|
||||
|
||||
Reference in New Issue
Block a user