Skip to content

Commit

Permalink
Fix premature handle scope closure
Browse files Browse the repository at this point in the history
  • Loading branch information
kasperisager committed Apr 5, 2024
1 parent d763d6f commit 4e1c6e0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/runtime.c
Original file line number Diff line number Diff line change
Expand Up @@ -1121,6 +1121,7 @@ bare_runtime_run (bare_runtime_t *runtime, const char *filename, bare_source_t s

case bare_source_arraybuffer:
args[1] = source.arraybuffer;
break;
}
}

Expand Down
10 changes: 6 additions & 4 deletions src/thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ bare_thread_entry (void *opaque) {

switch (thread->source.type) {
case bare_source_none:
case bare_source_arraybuffer:
source.type = bare_source_none;
break;

Expand All @@ -55,6 +54,9 @@ bare_thread_entry (void *opaque) {

memcpy(data, thread->source.buffer.base, thread->source.buffer.len);
break;

case bare_source_arraybuffer:
abort();
}

js_value_t *data;
Expand Down Expand Up @@ -90,9 +92,6 @@ bare_thread_entry (void *opaque) {

js_call_function(env, global, fn, 1, (js_value_t *[]){data}, NULL);

err = js_close_handle_scope(env, scope);
assert(err == 0);

uv_sem_post(&thread->lock);

bare_runtime_run(runtime, thread->filename, source);
Expand All @@ -105,6 +104,9 @@ bare_thread_entry (void *opaque) {

uv_sem_post(&thread->lock);

err = js_close_handle_scope(env, scope);
assert(err == 0);

err = bare_runtime_teardown(thread->runtime, NULL);
assert(err == 0);

Expand Down

0 comments on commit 4e1c6e0

Please sign in to comment.