pocketlang
pocketlang copied to clipboard
SIGSEGV on "import io" (and similar) when compiled without libs
How to reproduce:
- Modify
Makefile
.- Append
-DPK_NO_LIBS
to the CFLAGS - Remove the
./src/libs/
fromSRC_DIRS
- Append
-
make clean
and rebuild - Run
./pocket -c "import io"
and observe the segfault
Proposed fix:
diff --git a/src/core/vm.c b/src/core/vm.c
index 8b8eeaa..243dcc5 100644
--- a/src/core/vm.c
+++ b/src/core/vm.c
@@ -466,6 +466,7 @@ Var vmImportModule(PKVM* vm, String* from, String* path) {
uint32_t search_path_idx = 0;
do {
+ if (!vm->config.resolve_path_fn) break; // when compiled without libs
// If we reached here. It's not a native module (ie. module's absolute path
// is required to import and cache).
_resolved = vm->config.resolve_path_fn(vm, from_path, path->data);