From a95c4ded17a6be3e649ef88f259d7898e8d5843f Mon Sep 17 00:00:00 2001 From: Arshia Ghafoori Date: Wed, 18 Oct 2023 11:01:10 +0330 Subject: [PATCH] Fix class names not being null-terminated --- ion/src/class.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ion/src/class.rs b/ion/src/class.rs index b584b09f..0cc15f46 100644 --- a/ion/src/class.rs +++ b/ion/src/class.rs @@ -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; @@ -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(),