mirror of
https://github.com/janet-lang/janet
synced 2026-10-25 08:34:27 +00:00
reject short sourcemap and symbolmap entries in janet_asm1 (#1927)
This commit is contained in:
1 parent
cc57cf5bd7
commit
dc0f243bb9
2 files changed
+10
No files matched your search
@@ -721,6 +721,9 @@ static JanetAssembleResult janet_asm1(JanetAssembler *parent, Janet source, int
|
||||
janet_asm_error(&a, "expected tuple");
|
||||
}
|
||||
tup = janet_unwrap_tuple(entry);
|
||||
if (janet_tuple_length(tup) < 2) {
|
||||
janet_asm_error(&a, "sourcemap entry must have 2 elements");
|
||||
}
|
||||
if (!janet_checkint(tup[0])) {
|
||||
janet_asm_error(&a, "expected integer");
|
||||
}
|
||||
@@ -751,6 +754,9 @@ static JanetAssembleResult janet_asm1(JanetAssembler *parent, Janet source, int
|
||||
janet_asm_error(&a, "expected tuple");
|
||||
}
|
||||
tup = janet_unwrap_tuple(entry);
|
||||
if (janet_tuple_length(tup) < 4) {
|
||||
janet_asm_error(&a, "symbolmap entry must have 4 elements");
|
||||
}
|
||||
if (janet_keyeq(tup[0], "upvalue")) {
|
||||
ss.birth_pc = UINT32_MAX;
|
||||
} else if (!janet_checkint(tup[0])) {
|
||||
|
||||
@@ -66,5 +66,9 @@
|
||||
(def optimized (disasm (asm ~{:bytecode [(ldi 0 10) (movn 1 0) (add 2 0 1) (add 3 1 1) (add 4 0 0) (add 5 2 3) (ret 5)] :slotcount 40} :o) :bytecode))
|
||||
(assert (deep= optimized '@[(ldi 0 40) (ret 0)]) "bytecode optimization 1")
|
||||
|
||||
# short sourcemap/symbolmap entries must not read past the tuple
|
||||
(assert-error "short sourcemap entry" (asm '{:arity 0 :bytecode [(ret 0)] :sourcemap [[1]]}))
|
||||
(assert-error "short symbolmap entry" (asm '{:arity 0 :bytecode [(ret 0)] :symbolmap [[1 2 3]]}))
|
||||
|
||||
(end-suite)
|
||||
|
||||
Reference in new issue
Block a user