Skip to content

Commit 637d5da

Browse files
authored
Merge pull request #32 from FastVM/codex/locate-and-fix-important-bug
Fix load argument validation
2 parents b5e0b24 + 485e8c9 commit 637d5da

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

vm/std.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,13 @@ void vm_std_os_exit(vm_t *vm, vm_std_value_t *args) {
4747

4848
void vm_std_load(vm_t *vm, vm_std_value_t *args) {
4949
(void)vm;
50-
if (args[0].tag == VM_TAG_STR) {
51-
*args = (vm_std_value_t){
52-
.tag = VM_TAG_ERROR,
53-
.value.str = "cannot load non-string value",
54-
};
55-
}
50+
if (args[0].tag != VM_TAG_STR) {
51+
*args = (vm_std_value_t){
52+
.tag = VM_TAG_ERROR,
53+
.value.str = "cannot load non-string value",
54+
};
55+
return;
56+
}
5657
const char *str = args[0].value.str;
5758
vm_block_t *entry = vm_compile(vm, str);
5859

0 commit comments

Comments
 (0)