src: guard against calling Init()
multiple times
This function should only be called once. Calling it multiple times would currently break Node.js (e.g. re-registering builtin modules would break the linked list for them). PR-URL: https://github.com/nodejs/node/pull/26458 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
parent
3afa5d7ba8
commit
97ce5e0b4b
@ -608,9 +608,14 @@ int ProcessGlobalArgs(std::vector<std::string>* args,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static std::atomic_bool init_called{false};
|
||||
|
||||
int Init(std::vector<std::string>* argv,
|
||||
std::vector<std::string>* exec_argv,
|
||||
std::vector<std::string>* errors) {
|
||||
// Make sure Init() is called only once.
|
||||
CHECK(!init_called.exchange(true));
|
||||
|
||||
// Register built-in modules
|
||||
binding::RegisterBuiltinModules();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user