Skip to content
Permalink
Browse files Browse the repository at this point in the history
Disallow NativeModule creation unless main isolate
  • Loading branch information
laverdet committed Mar 18, 2021
1 parent b4ae52b commit 27151bf
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/module/native_module_handle.cc
Expand Up @@ -15,6 +15,9 @@ namespace ivm {
* RAII wrapper around libuv dlopen
*/
NativeModule::NativeModule(const std::string& filename) : init(nullptr) {
if (!IsolateEnvironment::GetCurrent()->IsDefault()) {
throw RuntimeGenericError("NativeModule may only be instantiated from default nodejs isolate");
}
if (uv_dlopen(filename.c_str(), &lib) != 0) {
throw RuntimeGenericError("Failed to load module");
}
Expand Down

0 comments on commit 27151bf

Please sign in to comment.