Skip to content

Commit

Permalink
Fix class names not being null-terminated
Browse files Browse the repository at this point in the history
  • Loading branch information
Arshia001 committed Oct 18, 2023
1 parent dc4ba58 commit a95c4de
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion ion/src/class.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use std::any::TypeId;
use std::collections::hash_map::Entry;
use std::ffi::CString;
use std::ptr;

use mozjs::glue::JS_GetReservedSlot;
Expand Down Expand Up @@ -75,13 +76,15 @@ pub trait ClassDefinition {
let static_properties = Self::static_properties();
let static_functions = Self::static_functions();

let name = CString::new(Self::NAME).unwrap();

let class = unsafe {
JS_InitClass(
cx.as_ptr(),
object.handle().into(),
parent_class,
parent_proto.handle().into(),
Self::NAME.as_ptr().cast(),
name.as_ptr().cast(),
Some(constructor),
nargs,
properties.as_ptr(),
Expand Down

0 comments on commit a95c4de

Please sign in to comment.