mirror of
https://github.com/nodejs/node.git
synced 2026-11-27 17:52:27 -05:00
module: refactor NativeModule to avoid unsafe array iteration
PR-URL: https://github.com/nodejs/node/pull/37656 Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: Zijian Liu <lxxyxzj@gmail.com>
This commit is contained in:
1 parent
a2d08d5dfd
commit
ae0e76c264
1 file changed
+4
-1
@@ -46,6 +46,7 @@
|
||||
const {
|
||||
ArrayPrototypeMap,
|
||||
ArrayPrototypePush,
|
||||
ArrayPrototypeSlice,
|
||||
Error,
|
||||
ObjectCreate,
|
||||
ObjectDefineProperty,
|
||||
@@ -239,8 +240,10 @@ class NativeModule {
|
||||
const { ModuleWrap } = internalBinding('module_wrap');
|
||||
const url = `node:${this.id}`;
|
||||
const nativeModule = this;
|
||||
const exportsKeys = ArrayPrototypeSlice(this.exportKeys);
|
||||
ArrayPrototypePush(exportsKeys, 'default');
|
||||
this.module = new ModuleWrap(
|
||||
url, undefined, [...this.exportKeys, 'default'],
|
||||
url, undefined, exportsKeys,
|
||||
function() {
|
||||
nativeModule.syncExports();
|
||||
this.setExport('default', nativeModule.exports);
|
||||
|
||||
Reference in new issue
Block a user