From 4cf0314766b4f63d50685f95998bbe278354f9d5 Mon Sep 17 00:00:00 2001 From: TheMas3212 Date: Sun, 17 Apr 2022 05:16:42 +1000 Subject: [PATCH] Fix leak of real Employee object in hireEmployee --- src/NetscriptFunctions/Corporation.ts | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/NetscriptFunctions/Corporation.ts b/src/NetscriptFunctions/Corporation.ts index a84958f4e..6ff8cb3c3 100644 --- a/src/NetscriptFunctions/Corporation.ts +++ b/src/NetscriptFunctions/Corporation.ts @@ -730,7 +730,22 @@ export function NetscriptCorporation( const divisionName = helper.string("hireEmployee", "divisionName", _divisionName); const cityName = helper.city("hireEmployee", "cityName", _cityName); const office = getOffice(divisionName, cityName); - return office.hireRandomEmployee(); + const employee = office.hireRandomEmployee(); + if (employee === undefined) return undefined; + return { + name: employee.name, + mor: employee.mor, + hap: employee.hap, + ene: employee.ene, + int: employee.int, + cha: employee.cha, + exp: employee.exp, + cre: employee.cre, + eff: employee.eff, + sal: employee.sal, + loc: employee.loc, + pos: employee.pos, + }; }, upgradeOfficeSize: function (_divisionName: unknown, _cityName: unknown, _size: unknown): void { checkAccess("upgradeOfficeSize", 8);