Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix segfault, handle symbol conversion correctly #319

Merged
merged 1 commit into from
Sep 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions ext/mini_racer_extension/mini_racer_extension.cc
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,7 @@ static VALUE convert_v8_to_ruby(Isolate* isolate, Local<Context> context,

Isolate::Scope isolate_scope(isolate);
HandleScope scope(isolate);
Context::Scope context_scope(context);

StackCounter stackCounter(isolate);

Expand Down Expand Up @@ -672,8 +673,9 @@ static VALUE convert_v8_to_ruby(Isolate* isolate, Local<Context> context,
}

if (value->IsSymbol()) {
v8::String::Utf8Value symbol_name(isolate,
Local<Symbol>::Cast(value)->Description(isolate));
Local<Symbol> symbol = Local<Symbol>::Cast(value);
Local<Value> description = symbol->Description(isolate);
v8::String::Utf8Value symbol_name(isolate, description);

VALUE str_symbol = rb_utf8_str_new(*symbol_name, symbol_name.length());

Expand Down
1 change: 1 addition & 0 deletions test/mini_racer_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -975,6 +975,7 @@ def test_pipe_leak
def test_symbol_support
context = MiniRacer::Context.new()
assert_equal :foo, context.eval("Symbol('foo')")
assert_equal :undefined, context.eval("Symbol()") # should not crash
end

def test_cyclical_object_js
Expand Down
Loading