From 27eed800a63e016b7b50bd6628d59876ad71afba Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Tue, 19 Sep 2023 16:57:25 +0200 Subject: [PATCH] vm: freeze `dependencySpecifiers` array --- lib/internal/vm/module.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/internal/vm/module.js b/lib/internal/vm/module.js index c77ee9b107e0ad..d9a073fd4d7906 100644 --- a/lib/internal/vm/module.js +++ b/lib/internal/vm/module.js @@ -7,6 +7,7 @@ const { ArrayPrototypeIndexOf, ArrayPrototypeSome, ObjectDefineProperty, + ObjectFreeze, ObjectGetPrototypeOf, ObjectSetPrototypeOf, ReflectApply, @@ -340,9 +341,7 @@ class SourceTextModule extends Module { if (this[kWrap] === undefined) { throw new ERR_VM_MODULE_NOT_MODULE(); } - if (this[kDependencySpecifiers] === undefined) { - this[kDependencySpecifiers] = this[kWrap].getStaticDependencySpecifiers(); - } + this[kDependencySpecifiers] ??= ObjectFreeze(this[kWrap].getStaticDependencySpecifiers()); return this[kDependencySpecifiers]; }