Compare commits

...

3 Commits

Author SHA1 Message Date
Jarred Sumner
310635ffe5 Update JSEnvironmentVariableMap.cpp 2025-09-02 01:42:42 -07:00
Jarred Sumner
6bc1872077 Update JSEnvironmentVariableMap.cpp 2025-09-02 01:36:13 -07:00
Jarred Sumner
f100b2bfe2 Fixes #20514 2025-09-02 01:24:07 -07:00
3 changed files with 26 additions and 6 deletions

View File

@@ -287,12 +287,18 @@ JSValue createEnvironmentVariablesMap(Zig::GlobalObject* globalObject)
void* list;
size_t count = Bun__getEnvCount(globalObject, &list);
JSC::JSObject* object = nullptr;
if (count < 63) {
object = constructEmptyObject(globalObject, globalObject->objectPrototype(), count);
} else {
object = constructEmptyObject(globalObject, globalObject->objectPrototype());
}
#if OS(WINDOWS)
object = JSC::constructEmptyObject(vm, globalObject->nullPrototypeObjectStructure());
#else
JSObject* prototype = globalObject->objectPrototype();
if (count < JSFinalObject::maxInlineCapacity) {
object = constructEmptyObject(globalObject, prototype, count);
} else {
object = constructEmptyObject(globalObject, prototype);
}
#endif
#if OS(WINDOWS)
JSArray* keyArray = constructEmptyArray(globalObject, nullptr, count);
RETURN_IF_EXCEPTION(scope, {});

View File

@@ -414,7 +414,7 @@ export function windowsEnv(
}
if (internalEnv[k] !== value) {
editWindowsEnvVar(k, value);
internalEnv[k] = value;
$putByValDirect(internalEnv, k, value);
}
return true;
},

View File

@@ -0,0 +1,14 @@
import { expect, test } from "bun:test";
// https://github.com/oven-sh/bun/issues/20514
test("test", () => {
expect([
"-p",
`Object.defineProperty(Object.prototype, "1", {
set: function (value) {
throw new Error();
}
});
const homeDir = process.env.HOME || process.env.USERPROFILE;`,
]).toRun();
});