Fix #3037: wrap user-supplied atExit function so that we can't accidentally leak game objects as 'this'

This commit is contained in:
Heikki Aitakangas 2022-02-26 01:00:02 +02:00
parent ee887de151
commit 66ceff4e33

@ -2279,7 +2279,7 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
if (typeof f !== "function") {
throw makeRuntimeErrorMsg("atExit", "argument should be function");
}
workerScript.atExit = f;
workerScript.atExit = () => { f(); }; // Wrap the user function to prevent WorkerScript leaking as 'this'
},
mv: function (host: string, source: string, destination: string): void {
updateDynamicRam("mv", getRamCost(Player, "mv"));