Skip to content

Commit 67133c0

Browse files
committed
(enh) disallow compiling into an existing named module
1 parent 60d0b70 commit 67133c0

File tree

3 files changed

+6
-0
lines changed

3 files changed

+6
-0
lines changed

deps/wren/src/optional/wren_opt_meta.c

+4
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ void metaCompile(WrenVM* vm)
1616
const char* module;
1717
if (wrenGetSlotType(vm, 2) != WREN_TYPE_NULL) {
1818
module = wrenGetSlotString(vm, 2);
19+
if (wrenHasModule(vm,module)) {
20+
wrenSetSlotString(vm, 0, "Security: Cannot compile into an existing named module.");
21+
wrenAbortFiber(vm, 0);
22+
}
1923
} else {
2024
// TODO: Allow passing in module?
2125
// Look up the module surrounding the callsite. This is brittle. The -2 walks

deps/wren/src/optional/wren_opt_meta.wren

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ class Meta {
77
Fiber.abort("Could not find a module named '%(module)'.")
88
}
99

10+
static eval(source) { eval(source, null) }
1011
static eval(source, module) {
1112
if (!(source is String)) Fiber.abort("Source code must be a string.")
1213

deps/wren/src/optional/wren_opt_meta.wren.inc

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ static const char* metaModuleSource =
1111
" Fiber.abort(\"Could not find a module named '%(module)'.\")\n"
1212
" }\n"
1313
"\n"
14+
" static eval(source) { eval(source, null) }\n"
1415
" static eval(source, module) {\n"
1516
" if (!(source is String)) Fiber.abort(\"Source code must be a string.\")\n"
1617
"\n"

0 commit comments

Comments
 (0)