From 97169185175c52f87fe64d004980105adadc1998 Mon Sep 17 00:00:00 2001 From: Alex Orlenko Date: Fri, 9 Dec 2022 23:55:38 +0000 Subject: [PATCH] Fix lifetime of `DebugNames` in `Debug::names()` and `DebugSource` in `Debug::source()`. This can cause use-after-free if used wrong. Now invalid code would not compile. Reported in #230 --- src/hook.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hook.rs b/src/hook.rs index 59d67ae..f52fec3 100644 --- a/src/hook.rs +++ b/src/hook.rs @@ -63,7 +63,7 @@ impl<'lua> Debug<'lua> { } /// Corresponds to the `n` what mask. - pub fn names(&self) -> DebugNames<'lua> { + pub fn names(&self) -> DebugNames { unsafe { #[cfg(not(feature = "luau"))] mlua_assert!( @@ -87,7 +87,7 @@ impl<'lua> Debug<'lua> { } /// Corresponds to the `S` what mask. - pub fn source(&self) -> DebugSource<'lua> { + pub fn source(&self) -> DebugSource { unsafe { #[cfg(not(feature = "luau"))] mlua_assert!(