diff --git a/src/value.rs b/src/value.rs index 4dfa0c12..4c8251b5 100644 --- a/src/value.rs +++ b/src/value.rs @@ -129,9 +129,14 @@ impl Value { #[inline] pub fn to_pointer(&self) -> *const c_void { match self { + Value::String(String(vref)) => { + // In Lua < 5.4 (excluding Luau), string pointers are NULL + // Use alternative approach + let lua = vref.lua.lock(); + unsafe { ffi::lua_tostring(lua.ref_thread(), vref.index) as *const c_void } + } Value::LightUserData(ud) => ud.0, - Value::String(String(vref)) - | Value::Table(Table(vref)) + Value::Table(Table(vref)) | Value::Function(Function(vref)) | Value::Thread(Thread(vref, ..)) | Value::UserData(AnyUserData(vref))