Skip to content

Commit

Permalink
Fixed Class Name Null Termination (#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
Arshia001 authored Oct 18, 2023
1 parent eef1f61 commit f0bcec4
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 f0bcec4

Please sign in to comment.