Skip to content

Commit

Permalink
critical sqlite bug fix and stack size increase
Browse files Browse the repository at this point in the history
  • Loading branch information
mcfriend99 committed Aug 22, 2024
1 parent e4f105b commit 2a564ef
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 20 deletions.
4 changes: 2 additions & 2 deletions packages/json/json.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ b_value get_blade_value(b_vm *vm, json_value * data) {
b_obj_dict *dict = (b_obj_dict*)GC(new_dict(vm));
value = OBJ_VAL(dict);
for (int i = 0; i < data->u.object.length; i++) {
b_obj_string *name = (b_obj_string *)GC(copy_string(vm, data->u.object.values[i].name, strlen(data->u.object.values[i].name)));
b_value name = GC_STRING(data->u.object.values[i].name);
b_value _value = get_blade_value(vm, data->u.object.values[i].value);
dict_set_entry(vm, dict, OBJ_VAL(name), _value);
dict_set_entry(vm, dict, name, _value);
}
break;
}
Expand Down
3 changes: 2 additions & 1 deletion packages/sqlite/sqlite.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ DECLARE_MODULE_METHOD(sqlite__exec) {
}

if(sqlite3_step(stmt) != SQLITE_DONE) {
RETURN_STRING("exec failed!");
const char *error = sqlite3_errmsg(db);
RETURN_STRING(error);
}

sqlite3_finalize(stmt);
Expand Down
2 changes: 1 addition & 1 deletion src/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@

#define UINT8_COUNT (UINT8_MAX + 1)
#define UINT16_COUNT (UINT16_MAX + 1)
#define STACK_MAX (FRAMES_MAX * UINT8_COUNT)
#define STACK_MAX (FRAMES_MAX * UINT16_COUNT)

#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
#define IS_UNIX
Expand Down
7 changes: 2 additions & 5 deletions src/compiler.c
Original file line number Diff line number Diff line change
Expand Up @@ -2223,13 +2223,10 @@ static void import_statement(b_parser *p) {
return;
}

b_blob blob;
init_blob(&blob);

b_obj_module *module = new_module(p->vm, module_name, module_path);

push(p->vm, OBJ_VAL(module));
b_obj_func *function = compile(p->vm, module, source, &blob);
b_obj_func *function = compile(p->vm, module, source);
pop(p->vm);

free(source);
Expand Down Expand Up @@ -2566,7 +2563,7 @@ static void statement(b_parser *p) {
ignore_whitespace(p);
}

b_obj_func *compile(b_vm *vm, b_obj_module *module, const char *source, b_blob *blob) {
b_obj_func *compile(b_vm *vm, b_obj_module *module, const char *source) {
b_scanner scanner;
init_scanner(&scanner, source);

Expand Down
2 changes: 1 addition & 1 deletion src/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ typedef struct {
b_precedence precedence;
} b_parse_rule;

b_obj_func *compile(b_vm *vm, b_obj_module *module, const char *source, b_blob *blob);
b_obj_func *compile(b_vm *vm, b_obj_module *module, const char *source);

void mark_compiler_roots(b_vm *vm);

Expand Down
2 changes: 1 addition & 1 deletion src/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ DECLARE_NATIVE(file) {
ENFORCE_ARG_TYPE(file, 1, IS_STRING);
mode = AS_STRING(args[1]);
} else {
mode = (b_obj_string *) GC(copy_string(vm, "r", 1));
mode = (b_obj_string *) GC(take_string(vm, strdup("r"), 1));
}

b_obj_file *file = (b_obj_file*)GC(new_file(vm, path, mode));
Expand Down
5 changes: 1 addition & 4 deletions src/standard/reflect.c
Original file line number Diff line number Diff line change
Expand Up @@ -280,14 +280,11 @@ DECLARE_MODULE_METHOD(reflect__runscript) {
char *path = AS_C_STRING(args[0]);
char *source = AS_C_STRING(args[1]);

b_blob blob;
init_blob(&blob);

b_obj_module *module = vm->current_frame->closure->function->module;
char *module_file = module->file;

module->file = path;
b_obj_func *fn = compile(vm, module, source, &blob);
b_obj_func *fn = compile(vm, module, source);
module->file = module_file;

if(fn != NULL) {
Expand Down
6 changes: 1 addition & 5 deletions src/vm.c
Original file line number Diff line number Diff line change
Expand Up @@ -2541,21 +2541,17 @@ bool queue_closure(b_vm *vm, b_obj_closure *closure) {
}

b_ptr_result interpret(b_vm *vm, b_obj_module *module, const char *source) {
b_blob blob;
init_blob(&blob);

if(vm->exception_class == NULL) {
initialize_exceptions(vm, module);
}

b_obj_func *function = compile(vm, module, source, &blob);
b_obj_func *function = compile(vm, module, source);

if (vm->should_exit_after_bytecode) {
return PTR_OK;
}

if (function == NULL) {
free_blob(vm, &blob);
return PTR_COMPILE_ERR;
}

Expand Down

0 comments on commit 2a564ef

Please sign in to comment.